Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

Player Class in J2ME

In J2ME, player class is used to play the .wav music, that is the only reason of using the class in our small application to create multimedia sounds.

Ads

Player Class in J2ME

     

Creating Multimedia Sound Using Player Class

In J2ME, player class is used to play the .wav music, that is the only reason of using the class in our small application to create multimedia sounds. It's required to import the javax.microedition.media package to use this class in our example. 

Please find the given methods and manager class that is used to create any multimedia sounds in J2ME..

Methods:

  • addPlayerListener(PlayerListener playerListener)
  • close()
  • deallocate()
  • getContentType()
  • getDuration()
  • getMediaTime()
  • getState()
  • prefetch()
  • realize()
  • removePlayerListener(PlayerListener playerListener)
  • setLoopCount(int count)
  • setMediaTime(long now)
  • start()
  • stop()

And the Manager class, that is having following Methods:

  • createPlayer(InputStream stream, String type)
  • createPlayer(String locator)
  • getSupportedContentTypes(String protocol)
  • getSupportedProtocols(String content_type)
  • playTone(int note, int duration, int volume)

Source Code of MultimediaSound.java

import javax.microedition.midlet.MIDlet;
import javax.microedition.media.*;

public class MultimediaSound extends MIDlet {
  public void startApp(){
  try {
  Player player = Manager.createPlayer(getClass().

  getResourceAsStream("/CatBird.wav"),"audio/x-wav");


  player.start();
  catch(Exception e) {
  e.printStackTrace();
  }
  }

  public void pauseApp() {}

  public void destroyApp(boolean unconditional) {}
}

Download Source Code

Advertisements

Ads
Share on Google+Share on Google+

Player Class in J2ME

Posted on: November 1, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Player Class in J2ME   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Amir
March 23, 2013
Urgent

I have written this code in Netbeans and it works but when I send my file to my cellphone it doesn't work,what should I do? Bests

Ads

 

Ads