Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home J2me Ring Tones MIDlet Example

Related Tutorials


Share on Google+Share on Google+

Ring Tones MIDlet Example

In this example only two Ring Tones are created using Player class.

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

import javax.microedition.midlet.*;
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(
"/kabhi-alvida-na-kehna.wav"), "audio/x-wav");
  player2 = Manager.createPlayer(getClass().getResourceAsStream(
"/aagepiche.wav"), "audio/x-wav");
  } 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 != null) player2.stop();
  }catch(MediaException e) {

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

Download Source Code


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 5, 2008

Related Tutorials

Discuss: Ring Tones MIDlet Example   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image