Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从BlackBerry应用程序启动录像机_Blackberry_Java Me - Fatal编程技术网

从BlackBerry应用程序启动录像机

从BlackBerry应用程序启动录像机,blackberry,java-me,Blackberry,Java Me,是否有启动视频录制应用程序的API?我想通过我的应用程序调用录像机,录制一段视频,然后将该视频保存到服务器 ApplicationManager.getApplicationManager().launch("net_rim_bb_videorecorder"); 这将帮助您打开应用程序。如果要开始录制,可能需要模拟按键输入 顺便说一句:CameraArguments(ARG_VIDEO_RECORDER)是从jde4.7开始引入的,因此它与以前的操作系统不兼容。因此,前面的方法更好。最终从B

是否有启动视频录制应用程序的API?我想通过我的应用程序调用录像机,录制一段视频,然后将该视频保存到服务器

ApplicationManager.getApplicationManager().launch("net_rim_bb_videorecorder");
这将帮助您打开应用程序。如果要开始录制,可能需要模拟按键输入


顺便说一句:
CameraArguments(ARG_VIDEO_RECORDER)
是从jde4.7开始引入的,因此它与以前的操作系统不兼容。因此,前面的方法更好。

最终从BB文档中找到解决方案。

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
import java.lang.*;
import javax.microedition.media.*;
import java.io.*;
import javax.microedition.media.control.*;

public class VideoRecordingDemo extends UiApplication
{
    public static void main(String[] args)
    {
         VideoRecordingDemo app = new VideoRecordingDemo();
         app.enterEventDispatcher();
    }

    public VideoRecordingDemo()
    {
         pushScreen(new VideoRecordingDemoScreen());
    }

    private class VideoRecordingDemoScreen extends MainScreen  
    {   
        private VideoRecorderThread _recorderThread;

        public VideoRecordingDemoScreen()
        {
            setTitle("Video recording demo");

            addMenuItem(new StartRecording());
            addMenuItem(new StopRecording());
        }

        private class StartRecording extends MenuItem 
        {
            public StartRecording() 
            {
                super("Start recording", 0, 100);
            }

            public void run() 
            {
                try 
                {
                    VideoRecorderThread newRecorderThread = new VideoRecorderThread();
                    newRecorderThread.start();
                    _recorderThread = newRecorderThread;
                }  
                catch (Exception e) 
                {
                    Dialog.alert(e.toString());
                }
            }
        }

        private class StopRecording extends MenuItem 
        {
            public StopRecording() 
            {
                super("Stop recording", 0, 100);
            }

            public void run() 
            {
                try 
                {
                    if (_recorderThread != null) 
                    { 
                        _recorderThread.stop();
                    }
                } 
                catch (Exception e) 
                {
                    Dialog.alert(e.toString());
                }
            }
        }

        private class VideoRecorderThread extends Thread implements javax.microedition.media.PlayerListener
        {
            private Player _player;
            private RecordControl _recordControl;

            VideoRecorderThread()
            {
            }

            public void run() 
            {
                try 
                {
                    _player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=video/3gpp");

                    _player.addPlayerListener(this);

                    _player.realize();
                    VideoControl videoControl = (VideoControl) _player.getControl("VideoControl");
                    _recordControl = (RecordControl) _player.getControl( "RecordControl" ); 

                    Field videoField = (Field) videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");

                    try
                    {
                        videoControl.setDisplaySize( Display.getWidth(), Display.getHeight() );
                    }
                    catch( MediaException me )
                    {
                        // setDisplaySize is not supported
                    }

                    add(videoField);

                    _recordControl.setRecordLocation("file:///store/home/user/VideoRecordingTest.3gpp" );   

                    _recordControl.startRecord(); 
                    _player.start();

                }
                catch( IOException e ) 
                {
                    Dialog.alert(e.toString());
                }
                catch( MediaException e ) 
                {
                    Dialog.alert(e.toString());
                }
            }
            public void stop() 
            {
                if (_player != null) 
                {
                     _player.close();
                     _player = null;
                }

                if (_recordControl != null) 
                {
                    _recordControl.stopRecord();

                    try 
                    {
                        _recordControl.commit();
                    } 
                    catch (Exception e) 
                    {
                        Dialog.alert(e.toString());
                    }
                    _recordControl = null;
                } 
            }

            public void playerUpdate(Player player, String event, Object eventData) 
            {
                Dialog.alert("Player " + player.hashCode() + " got event " + event + ": " + eventData);
            }
        }
    }
}