java left logo
java middle logo
java right logo
 

Home arrow Java ME Tips arrow MIDP arrow Finding multimedia content-type support of a mobile device
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4095
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Finding multimedia content-type support of a mobile device E-mail
User Rating: / 80
PoorBest 

MMAPI gives facility of playing audio/video on mobile phones. MMAPI's content-type/protocol support depends upon the mobile device capabilities. For example Motorola/A1000 handset supports midi, wav, amr but Motorola/E1000 handset support midi, mp3, wav, amr, wb-amr, aac, wma.

The example below displays the mulitmedia file formats that are supported on a mobile phone:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.Manager;

public class MultiMediaDeviceMidlet extends MIDlet 
  implements CommandListener 
{
  private static final Command exit = new Command(
    "Exit", Command.EXIT,1);
  private static final Command detail = new Command(
    "Details", Command.ITEM,1);
  private static final Command audio = new Command(
    "Audio", Command.ITEM,1);
  private static final Command vedio = new Command(
    "Video", Command.ITEM,1);
  private static final Command polyphonic = new Command(
    "Polyphonic sound", Command.ITEM,1);
  private Display display;
  private List list;

  public void startApp() 
  {
    if (display == null
    {
      display = Display.getDisplay(this);
      list = new List(
        "MultiMedia Device Capabilities", List.IMPLICIT, 
        Manager.getSupportedContentTypes(null),null);

      list.setCommandListener(this);
      list.addCommand(exit);
      list.addCommand(detail);
      list.addCommand(audio);
      list.addCommand(vedio);
      list.addCommand(polyphonic);

      deviceCapabilities();

    }
    display.setCurrent(list);
  }

  public void pauseApp() {}

  public void destroyApp(boolean unconditional) {}

  public void commandAction(Command c, Displayable d
  {
    if (c == exit
    {
      destroyApp(true);
      notifyDestroyed();
    
    if (c == detail
    {
      showDetails();
    
    if (c == audio
    {
      display.setCurrent(new Alert("audio",
        getCaptureSupport("audio"),null,AlertType.INFO));
    
    if (c == vedio
    {
      display.setCurrent(new Alert("video",
        getCaptureSupport("video"),null,AlertType.INFO));
    
    if (c == polyphonic
    {
      display.setCurrent(new Alert("Polyphony",
        getPolyphonySupport(),null,AlertType.INFO));
    }
  }

  private void showDetails() 
  {
    int index = list.getSelectedIndex();
    String type = list.getString(index);
    String protocols[] = Manager.getSupportedProtocols(type);
    Alert alert = new Alert(type, arrayToString(protocols)
      null, AlertType.INFO);
    display.setCurrent(alert);
  }

  private String arrayToString(String[] items
  {
    if ((items == null|| (items.length == 0)) 
    {
      return "";
    
    else 
    {
      StringBuffer buffer = new StringBuffer(items[0]);
      for (int i=1; i<items.length; i++
      {
        buffer.append(", ");
        buffer.append(items[i]);
      }
      return buffer.toString();
    }
  }

  private void deviceCapabilities() 
  {
    String types[] = Manager.getSupportedContentTypes(null);
    for (int i=0; i<types.length; i++
    {
      String protocols[] 
        Manager.getSupportedProtocols(types[i]);
    }
  }

  private String getCaptureSupport(String media
  {
    StringBuffer sbuf = new StringBuffer(media);
    String support = System.getProperty(
      "supports."+media+".capture");
      
    if ((support !=null&& (! support.trim().equals(""))) 
    {
      sbuf.append(" capture supported");
      String supportRecording =System.getProperty(
        "supports.recording");
      if ((supportRecording !=null&& 
        (! supportRecording.trim().equals(""))) 
      {
        String recordingEncodings = 
          System.getProperty(media+".encodings");
        if ((recordingEncodings != null&& 
          (! recordingEncodings.trim().equals(""))) 
        {
          sbuf.append(", recording supported to ");
          sbuf.append(recordingEncodings);
        
        else 
        {
          sbuf.append(", recording not supported for this media format");
        }
      
      else 
      {
        sbuf.append(", recording not supported");
      }

      String snapshotEncodings = System.getProperty(
        media+".snapshot.encodings");
        
      if (snapshotEncodings != null
      {
        sbuf.append(", snapshots supported to ");
        sbuf.append(snapshotEncodings);
      }
    
    else 
    {
      sbuf.append(" capture not supported");
    }
    return sbuf.toString();
  }

  private String getPolyphonySupport() 
  {
    String mixing = System.getProperty("supports.mixing");
    if (mixing !=null
    {
      return "Polyphonic sound supported";
    
    else 
    {
      return "Polyphonic sound not supported";
    }
  }
}


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.