Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom
Accepted Solution

Recording a video

Hi all,

 

I would like to record amd save a Video in my app, there is not a lot of info on this on the forums. 

 

I dont want to invoke the camera like "Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());"

 

and the following code snippet gives me a blank screen http://docs.blackberry.com/en/developers/deliverables/17968/Record_video_to_a_file_in_a_BB_device_ap...

 

Please can someone supply me with a helpful link or some example that might help me.

 

Thank you

Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: Recording a video

okay i have accomplished to get the video saved , to start and stop it, but when I try and play the video it says "Fiel not supported", How can i fix this? it there a specific piece of code that retreives the supported formats and is there a list of all the video formats?

 

Here is my Code:

public class MyScreen extends MainScreen{
	String PATH;
	RecordControl _recordControl;
	Player _player;
	MenuItem RecordVideo;
	MenuItem StopVideo;
	MenuItem SaveVideo;
	/*public static boolean SdcardAvailabulity() {
    	 String root = null;
    	 Enumeration e = FileSystemRegistry.listRoots();
    	 while (e.hasMoreElements()) {
    		 root = (String) e.nextElement();
    		 if( root.equalsIgnoreCase("sdcard/") ) {
    			 return true;
    		 }else if( root.equalsIgnoreCase("store/") ) {
    			 return false;
    		 }
    	 }
    	 class MySDListener implements FileSystemListener {
    		 public void rootChanged(int state, String rootName) {
    			 if( state == ROOT_ADDED ) {
    				 if( rootName.equalsIgnoreCase("sdcard/") ) {
    				 }
    			 } else if( state == ROOT_REMOVED ) {
    			 }
    		 }
    	 }
    	 return true;
 	}*/
	 public MyScreen(){
	    /*if(SdcardAvailabulity()){
                 PATH = System.getProperty("fileconn.dir.memorycard.photos")+"Image_"+System.currentTimeMillis()+".jpg";//here "str" having the current Date and Time;
            } else {
                 PATH = System.getProperty("fileconn.dir.photos")+"Image_"+System.currentTimeMillis()+".jpg"; 
            }*/
		 try {
			 _player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=video/3gpp");
			 _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 ){
            	 Dialog.alert("Display size not supported");
             }
             add(videoField);
             _recordControl.setRecordLocation("file:///store/home/user/videos/VideoRecordingTest.3gpp" );   
             _player.start();
			 _recordControl.startRecord();    
		 }catch( IOException e ){
             Dialog.alert(e.toString());
         } catch( MediaException e ){
             Dialog.alert(e.toString());
         } 
         RecordVideo = new MenuItem("Start Recording", 0, 0){
        	 public void run() {
        		 try {
					_player.start();
					 _recordControl.startRecord(); 
				} catch (MediaException e) {
					Dialog.alert("Error Starting recording");
					e.printStackTrace();
				}
			}
        };
        StopVideo = new MenuItem("Stop Recording", 0, 0){
       		 public void run() {
       			try {
					_player.stop();
					
				} catch (MediaException e) {
					Dialog.alert("Error Stopping recording");
					e.printStackTrace();
				}
			}
        };
        SaveVideo = new MenuItem("Save Video", 0, 0){
      		 public void run() {
      			try {
      			    // Create an invocation instance with the specified URL where the file type is one of the media types supported by the media player.
      			    Invocation invocation = new Invocation("file:///SDCard/BlackBerry/music/001.mp3"); 

      			    // Get the Registry object using the class name of the application   	
      			    Registry _registry=Registry.getRegistry(Application.getApplication().getClass().getName()); 

      			    //Invoke the content handler.
      			    _registry.invoke(invocation);
      			} catch (IOException e) 
      			{      }

 			}
         };
	 }
	 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;
         } 
     }
	 protected void makeMenu(Menu menu, int instance) {
			ContextMenu contextMenu = ContextMenu.getInstance();
			contextMenu.setTarget(this);
			contextMenu.clear();
			this.makeContextMenu(contextMenu);
			menu.deleteAll();
			menu.add(contextMenu);
		}
		
		public void makeContextMenu(ContextMenu contextMenu) {
			contextMenu.addItem(MenuItem.separator(32));
			contextMenu.addItem(RecordVideo);
			contextMenu.addItem(StopVideo);
			contextMenu.addItem(SaveVideo);
		}

}

 

Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: Recording a video

[ Edited ]

I used the code in the following link, and I get "The Media being Dislayed is of an unsupported format" the Phone I am using to test is a Blackberry 9780 and there is no memory card inserted... Any help ?? Please Smiley Happy

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-record-audio-and-Video-in-the-same-ti...

Trusted Contributor
Posts: 176
Registered: ‎04-12-2012
My Device: Bold 9780 & Curve 8250
My Carrier: vodacom

Re: Recording a video

[ Edited ]

MP4 Seems to work with the code in the below link, But I cant understand why 3gp doesnt work because it is supported by the handheld ?

http://supportforums.blackberry.com/t5/Java-Development/How-to-record-audio-and-Video-in-the-same-ti...