[an error occurred while processing this directive]

Ring Tones MIDlet Example


In this example only two Ring Tones are created using Player class. Find the given methods that are used in player class :

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

The Application is as follows:


Source Code of RingTones.java


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

public class RingTones extends MIDlet implements ItemStateListener, 
  private Display display;    
  private Form form;      
  private Command exit;     
  private ChoiceGroup choice;
  private Player player1, player2;

  public void startApp(){
    try {
      player1 = Manager.createPlayer(getClass().getResourceAsStream(
      player2 = Manager.createPlayer(getClass().getResourceAsStream(
    catch(MediaException e) {
    }catch(IOException ioe){
    display = Display.getDisplay(this);
    choice = new ChoiceGroup("List of RingTones", Choice.EXCLUSIVE);
    choice.append("Kabhi Alvida Na Kehna"null);    
    choice.append("Golmaal Return"null);    
    exit = new Command("Exit", Command.EXIT, 1);
    form = new Form("Playing song");

  public void pauseApp(){}

  public void destroyApp(boolean unconditional){

  public void commandAction(Command c, Displayable s){
    String label = c.getLabel();

  public void itemStateChanged(Item item){
      case 0:
          if(player2 != nullplayer2.stop();
        }catch(MediaException e) {

      case 1:
          if(player1 != nullplayer1.stop();
        }catch(MediaException e) {


Download Source Code


[an error occurred while processing this directive]