BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-13-2008, 06:36 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Nov 2007
Location: atm: Kunming norm: Berlin
Model: 8700v
PIN: N/A
Carrier: ChinaMobile
Posts: 55
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default playing videos on blackberry in j2me app...

Please Login to Remove!

Hi,
I'm working on an application which downloads videos and plays them(no streaming).
The Videos are downloaded correctly (I can play them in the BB MediaPlayer) but in my application the video isnt shown correctly (the sound works fine).

I work with an J2ME Polish application which should be ported to BB. Is it possible that the problem is, that the Player (javax.microedition.media.Player) is held in an J2ME - FORM and not in a BB-screen?

I tested the Player in an "normal" BB-screen and everything works fine...
(so the Player seems to be implemented correctly, the only difference is the Form instead of a Screen)

Does anybody know this problem?
Thanks in advance
JJ

PS: another question: I read in several articles that since v4.2 it is possible to invoke the BB Mediaplayer but I cant find the according arguments in the Invoke api...Is it possible to invoke the BB MP? and when how?

Last edited by jenselense : 11-13-2008 at 06:38 AM.
Offline  
Old 11-25-2008, 04:36 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Nov 2007
Location: atm: Kunming norm: Berlin
Model: 8700v
PIN: N/A
Carrier: ChinaMobile
Posts: 55
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey...
I found out what the problem was/is. It had nothing to do with the Container the video is shown in (in a Form or in a BB-Screen...). The error appears only if the video's size is changed (VideoControl.setDisplaySize() ). And only if its WIDTH is changed. When I change the height everything is fine...

Is this a known issue? What do I do wrong?
I use
videoControl.initDisplayMode(VideoControl.USE_DIRE CT_VIDEO, this);
where "this" is a VerticalFieldManager.
When I start the video in FullScreen or with changed height it looks good but when I change the width the video gets askew. when the width is only changed by 2 pixel or less you still can recognize the video but see that it is askew...

????????
Offline  
Old 11-26-2008, 08:07 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Nov 2007
Location: atm: Kunming norm: Berlin
Model: 8700v
PIN: N/A
Carrier: ChinaMobile
Posts: 55
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

if noone knows this problem, maybe one of you could test it on your pc just to let me know I'm not completely stupid...

my "startscreen":

Code:
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class StartScreen extends MainScreen{
	
	public StartScreen(){
		this.add(new RichTextField("HELLO"));
		this.add(new VideoScreen());
	}
}

and the mainpart, the "videoscreen":


Code:
import java.io.IOException;

import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;
import javax.microedition.media.PlayerListener;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.container.HorizontalFieldManager;



public class VideoScreen extends HorizontalFieldManager implements FieldChangeListener,PlayerListener{
	ButtonField startButton1;	
	Player mp;
	
	public VideoScreen(){
		startButton1 = new ButtonField("start1",ButtonField.CONSUME_CLICK);
		startButton1.setChangeListener(this);		
		try {
			mp = Manager.createPlayer("file:///store/samples/videos/BlackBerry.mp4");
			mp.realize();
			
			VideoControl videoControl = (VideoControl)mp.getControl( "javax.microedition.media.control.VideoControl");
			
			videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
                        // if this line is not commented out the error will appear...WHY???
			//videoControl.setDisplaySize(224, 168);

                        // this line would work fine:
			//videoControl.setDisplaySize(320, 200);

                        // this line wouldn't:
			//videoControl.setDisplaySize(318, 240);

			videoControl.setVisible(true);
			
		} catch (IOException e) {
			System.out.println("1"+e);
			e.printStackTrace();
		} catch (MediaException e) {
			System.out.println("2"+e);
			e.printStackTrace();
		}
		this.add(startButton1);
	}
	
	public void fieldChanged(Field field, int context) {
		System.out.println("start..");
		ButtonField button;
		if(field instanceof ButtonField){
			button = (ButtonField) field;
			if(button == startButton1){
				try {
					mp.start();
				} catch (MediaException e) {
					System.out.println("3: "+e);
					e.printStackTrace();
				}				
			}

		}


		
	}

	public void playerUpdate(Player player, String event, Object eventData) {
		// TODO Auto-generated method stub
		
	}
	
	public boolean keyDown(int keycode, int time) {
	     if(Keypad.map(keycode) == Keypad.KEY_SPACE){
	    	 try {
	    		 mp.setMediaTime(mp.getMediaTime()-2000000);
				} catch (MediaException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	     }
	     else if(Keypad.map(keycode) == Keypad.KEY_ESCAPE){
	    	 try {
	    		 mp.stop();
			} catch (MediaException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	     }
	     return(true);
	   }
	
}

Any ideas?????
Thanks in advance
JJ


EDIT: by the way: the same error occurs when I use
Code:
Field videoField = (Field)videoControl.initDisplayMode( VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );
and no Exception is thrown...

Last edited by jenselense : 11-26-2008 at 08:56 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.