Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Audio MIDlet Example 
 

This example illustrates how to play audio songs in your mobile application by creating a MIDlet.

 

Audio MIDlet Example

                         

This example illustrates how to play audio songs in your mobile application by creating a MIDlet. In the application we have created a player for an audio song by using of javax.microedition.media API. As you know we have already created two player for two different songs and want to play both song in an application at a time.

Before creating of MIDlet we need the wav file in res folder which we are using in our MIDlet. In the application program, three methods are used of Player class, that are:

  • realize()
  • prefetch()
  • start()

The realize() method is used to Constructs portions of the Player without acquiring the scarce and exclusive resources, the prefetch() method is used to Acquires the scarce and exclusive resources and processes as much data as necessary to reduce the start latency and the start() method is used to Starts the Player as soon as possible.

The Application is as follows:

Source Code of AudioMIDlet.java

 
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.*;
import javax.microedition.midlet.*;
//import javax.microedition.media.TimeBase;

public class AudioMIDlet extends MIDlet{

  Player p1, p2;
  
  public void startApp(){
    try {

      p1 = Manager.createPlayer(getClass().getResourceAsStream(
           "/kabhi-alvida-na-kehna.wav"
)"audio/x-wav");
      p1.realize();

      p2 = Manager.createPlayer(getClass().getResourceAsStream(
           "/aagepiche.wav"
)"audio/x-wav");
      p2.realize();

      //p2.setTimeBase(p1.getTimeBase());

      p1.prefetch();
      p2.prefetch();

      p1.start();
      p2.start();

    }catch(IOException ioe){

    }catch(MediaException me){}
  }

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){}
}

Download Source Code

                         

» View all related tutorials
Related Tags: c io vi lock this block set frame example ram exam locks e il manual blocks man in as m

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.