Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4235428
  • 博文数量: 176
  • 博客积分: 10059
  • 博客等级: 上将
  • 技术积分: 4681
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-24 12:27
文章分类

全部博文(176)

文章存档

2012年(1)

2011年(4)

2010年(14)

2009年(71)

2008年(103)

分类: Java

2008-04-27 10:52:42

在进行媒体播放程序设计前,有必要得知当前硬件设备所支持的媒体格式和处理能力。这些信息可以通过System.getProperty方法获得,返回值是一个字符串型变量。MMAPI提供了下面7种属性:


Key Description
supports.mixing Query for whether audio mixing is supported. The string returned is either "true" or "false". If mixing is supported, the following conditions are true:
  • At least two tones can be played with Manager.playTone simultaneously.
  • Manager.playTone can be used at the same time when at least one Player is playing back audio.
  • At least two Player's can be used to play back audio simultaneously.
supports.audio.capture Query for whether audio capture is supported. The string returned is either true or false.
supports.video.capture Query for whether video capture is supported. The string returned is either true or false.
supports.recording Query for whether recording is supported. The string returned is either true or false.
audio.encodings The string returned specifies the supported capture audio formats. Each format is specified in a . The formats are delimited by at least one space.
video.encodings The string returned specifies the supported capture video formats. Each format is specified in a . The formats are delimited by at least one space.
video.snapshot.encodings Supported video snapshot formats for the method in VideoControl. The string returned specifies the supported capture image formats. Each format is specified in a . The formats are delimited by at least one space.

查询类:

package zieckey.j2me.study.mmapi;

public class AppRuntimeDetect
{
    public static boolean CAPTURE_PHOTO = false;
    public static boolean CAPTURE_VIDEO = false;
    public static boolean CAPTURE_AUDIO = false;
    public static boolean IS_MIDP2 = false;
    
    static
    {
        //判断是否支持录音

        CAPTURE_AUDIO = "true".equals( System.getProperty( "supports.audio.capture" ) ) ? true : false;
        //判断是否支持录像

        CAPTURE_VIDEO = "true".equals( System.getProperty( "supports.video.capture" ) ) ? true : false;
        
        //判断MIDP版本

        String platform = System.getProperty( "microedition.profiles" );
        if ( -1 != platform.indexOf("MIDP-2.0" ) )
        {
            IS_MIDP2 = true;
        }
        
        //判断是否支持拍照

        String snapshot = System.getProperty( "video.snapshot.encodings" );
        if ( snapshot != null )
        {
            CAPTURE_PHOTO = true;
        }
    }
}


显示类:

package zieckey.j2me.study.mmapi;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
 * 本程序用来说明获得当前硬件设备的媒体处理能力集的方法
 * @author zieckey
 */

public class ConfigMIDlet extends MIDlet implements CommandListener
{

    private Display    display;
    private Command    cmdExit;
    private List    menu;

    public ConfigMIDlet( )
    {
        display = Display.getDisplay( this );// 提取系统设备的Display对象

        cmdExit = new Command( "Exit", Command.SCREEN, 2 );// 对该菜单的相应应用到当前整个屏幕

    }

    protected void startApp() throws MIDletStateChangeException
    {

        // 构造一List组件,用于显示文本

        menu = new List( "Main", List.IMPLICIT );

        if ( AppRuntimeDetect.CAPTURE_AUDIO )
        {
            menu.append( "Capture audio", null );
        }
        if ( AppRuntimeDetect.CAPTURE_VIDEO )
        {
            menu.append( "Capture video", null );
        }
        if ( AppRuntimeDetect.IS_MIDP2 )
        {
            menu.append( "Is MIDP 2.0", null );
        }
        if ( AppRuntimeDetect.CAPTURE_PHOTO )
        {
            menu.append( "Capture photo", null );
        }
        
        menu.addCommand( cmdExit );
        menu.setCommandListener( (CommandListener)this );

        // 将menu设置为当前显示的组件

        display.setCurrent( menu );
    }

    protected void destroyApp( boolean arg0 ) throws MIDletStateChangeException
    {
    }

    protected void pauseApp()
    {
    }

    public void commandAction( Command cmd, Displayable arg1 )
    {
        // 对该命令的响应

        if ( cmd == cmdExit )
        {
            try
            {
                destroyApp( true );
            } catch ( MIDletStateChangeException e )
            {
                e.printStackTrace( );
            }
            notifyDestroyed( );
        }
    }
}

阅读(2566) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-07-01 18:00:54

//判断是否支持录像 我想问下 你说的这个录像是手机本身的那个 摄像机的摄像功能吗?谢谢