HTC Diamond可以使用j2me支持MMAPI吗

发布于 2024-12-09 10:06:40 字数 3016 浏览 0 评论 0原文

我想让我的j2me项目能够使用MMAPI(JSR135)拍摄照片 因此,我使用以下代码检查我的 HTC Diamond

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

public class jsrtest extends MIDlet implements Runnable,CommandListener{
    Form form;
    Thread thread;
    Command c=new Command("Exit",Command.EXIT,0);
    public jsrtest()
    {
        Display.getDisplay(this).setCurrent(form=new Form("JSR Test"));
        form.addCommand(c);
        form.setCommandListener(this);
        (thread=new Thread(this)).start();
    }
    protected void destroyApp(boolean u){
        super.notifyDestroyed();
    }
    protected void pauseApp() {
    }
    protected void startApp(){
    }
    public void run() {
        checkJSR("MIDP2.0","javax.microedition.lcdui.game.GameCanvas");
        checkJSR("CLDC1.1","java.lang.Float");
        checkJSR("MMAPI","javax.microedition.media.Player");
        checkJSR("WMAPI","javax.wireless.messaging.Message");
        checkJSR("JSR75","javax.microedition.io.file.FileConnection");
        checkJSR("JSR082","javax.bluetooth.UUID");
        checkJSR("JSR135","javax.microedition.media.Control");
        checkJSR("JSR135_videocontrol","javax.microedition.media.control.VideoControl");
        checkJSR("JSR179","javax.microedition.location.Location");
        checkJSR("JSR180","javax.microedition.sip.SipConnection");
        checkJSR("JSR184","javax.microedition.m3g.Mesh");
        checkJSR("JSR211","javax.microedition.content.Registry");
        checkJSR("JSR226","javax.microedition.m2g.SVGImage");
        checkJSR("JSR229","javax.microedition.payment.TransactionRecord");
        checkJSR("JSR234","javax.microedition.amms.Module");
        checkJSR("JSR238","javax.microedition.global.Formatter");
        checkJSR("JSR239","javax.microedition.khronos.egl.EGL");
    }
    private void checkJSR(String jsr,String className)
    {
        try {
            Class.forName(className);
            form.append(jsr+" Supproted\n");
        } catch (ClassNotFoundException e) {
            form.append(jsr+" Not Supproted\n");
        }
    }
    public void commandAction(Command cmd, Displayable disp) {
        this.destroyApp(false);
    }
}

,该代码显示 HTC Diamond 支持 MMAPI。

所以我在我的 HTC Diamond 上测试了以下代码,看看相机是否工作但失败了:

private void test(){
     Player p;
     VideoControl vc;
     try{
       p = Manager.createPlayer("capture://video");
       p.realize();
       vc = (VideoControl) p.getControl("VideoControl");
       form.append(new StringItem("mmmmmmmm",""));
       if (vc != null) {
        form.append((Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null));
       }
       p.start();
     }catch(Exception e){
        e.printStackTrace();
     }

}

上面的代码在 JAVA ME Platform SDK 3 上工作正常。 谁能告诉我为什么 MMAPI 不能在我的手机上使用?

I wanted to let my j2me project have the ability to take picutre using MMAPI(JSR135)
So I check my HTC Diamond with the following code

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

public class jsrtest extends MIDlet implements Runnable,CommandListener{
    Form form;
    Thread thread;
    Command c=new Command("Exit",Command.EXIT,0);
    public jsrtest()
    {
        Display.getDisplay(this).setCurrent(form=new Form("JSR Test"));
        form.addCommand(c);
        form.setCommandListener(this);
        (thread=new Thread(this)).start();
    }
    protected void destroyApp(boolean u){
        super.notifyDestroyed();
    }
    protected void pauseApp() {
    }
    protected void startApp(){
    }
    public void run() {
        checkJSR("MIDP2.0","javax.microedition.lcdui.game.GameCanvas");
        checkJSR("CLDC1.1","java.lang.Float");
        checkJSR("MMAPI","javax.microedition.media.Player");
        checkJSR("WMAPI","javax.wireless.messaging.Message");
        checkJSR("JSR75","javax.microedition.io.file.FileConnection");
        checkJSR("JSR082","javax.bluetooth.UUID");
        checkJSR("JSR135","javax.microedition.media.Control");
        checkJSR("JSR135_videocontrol","javax.microedition.media.control.VideoControl");
        checkJSR("JSR179","javax.microedition.location.Location");
        checkJSR("JSR180","javax.microedition.sip.SipConnection");
        checkJSR("JSR184","javax.microedition.m3g.Mesh");
        checkJSR("JSR211","javax.microedition.content.Registry");
        checkJSR("JSR226","javax.microedition.m2g.SVGImage");
        checkJSR("JSR229","javax.microedition.payment.TransactionRecord");
        checkJSR("JSR234","javax.microedition.amms.Module");
        checkJSR("JSR238","javax.microedition.global.Formatter");
        checkJSR("JSR239","javax.microedition.khronos.egl.EGL");
    }
    private void checkJSR(String jsr,String className)
    {
        try {
            Class.forName(className);
            form.append(jsr+" Supproted\n");
        } catch (ClassNotFoundException e) {
            form.append(jsr+" Not Supproted\n");
        }
    }
    public void commandAction(Command cmd, Displayable disp) {
        this.destroyApp(false);
    }
}

which shows MMAPI is supported on HTC Diamond.

so I test the following code on my HTC Diamond to see if camera works but failed:

private void test(){
     Player p;
     VideoControl vc;
     try{
       p = Manager.createPlayer("capture://video");
       p.realize();
       vc = (VideoControl) p.getControl("VideoControl");
       form.append(new StringItem("mmmmmmmm",""));
       if (vc != null) {
        form.append((Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null));
       }
       p.start();
     }catch(Exception e){
        e.printStackTrace();
     }

}

On above code works fine on JAVA ME Platform SDK 3.
Can anybody tell me why MMAPI doesn't works my mobile phone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

合久必婚 2024-12-16 10:06:40

您可以进行额外的测试,看看是否支持视频捕获:

if(System.getProperty("supports.video.capture") == null){
    //Video capture not supported
}

但我认为主要问题在这一行:

form.append((Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null));

试试这个:

    vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, <a Canvas here>);
    vc.setDisplayFullScreen(true);
    vc.setVisible(true);

You can make an additional test to see if the video capture is supported:

if(System.getProperty("supports.video.capture") == null){
    //Video capture not supported
}

But I think the main problem is on this line:

form.append((Item)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null));

try this:

    vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, <a Canvas here>);
    vc.setDisplayFullScreen(true);
    vc.setVisible(true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文