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
New Developer
Posts: 6
Registered: ‎10-23-2009
My Device: Not Specified
Accepted Solution

Play video works on simulator, but not on phone

Hi,

 

I created a simple application that  plays a video from Media Card. It works fine and play the video correctly on simulators. But when I loaded the application on to the phone (BB Bold), it just show a white screen and no video.

 

The media file exists in the following path on the media card:

 

/Media Card/BlackBerry/videos/I66.3GP

 

Should the path be:

 

file:///SDCard/BlackBerry/videos/I66.3GP

OR

file:///Media Card/BlackBerry/videos/I66.3GP

 

 Any suggestions on how to get it to work on the phone??

 


 

 

final class VideoScreen extends MainScreen {
private Player player;
private VideoControl vc;

VideoScreen() {
try {

 player = Manager.createPlayer("file:///SDCard/BlackBerry/videos/I66.3GP");
 player.realize();
 vc = (VideoControl) player.getControl("VideoControl");
    vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
     
    GUIControl gc;
    if ((gc = (GUIControl) player.getControl("GUIControl")) !=null)
      add((Field) gc.initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null));
    vc.setDisplayLocation(15, 15);
    vc.setDisplaySize(400, 400);
    vc.setVisible(true);
    player.start();
  
} catch (Exception e) { }
}
}

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Play video works on simulator, but not on phone

Any exceptions generated?


Use Search. "Accept Solution" If the problem is resolved.
New Developer
Posts: 6
Registered: ‎10-23-2009
My Device: Not Specified

Re: Play video works on simulator, but not on phone

No, no exception generated. I added exception handling and did not see any problem.

 

Here's the settings on options/memory:

 

 

Media Card Support : On

Encryption Mode: None

Mass Storage support: On

Auto Enable Mass Storage: Yes

 

Any ideas??

New Developer
Posts: 6
Registered: ‎10-23-2009
My Device: Not Specified

Re: Play video works on simulator, but not on phone

You are right! There is an exception, I didn't display it at the right place. It's prompting:

 

"java.io.IOException: Locator does not reference a valid media file".

 

So here's my question, if I view the properties of the media file that I want to display, and it exists at:

/Media Card/Blackberry/videos/I66.3GP

 

In the code, I have tried the following:

1. player = Manager.createPlayer("file:///SDCard/BlackBerry/videos/I66.3GP");

This is giving me the "invalid media file" error.

 

2. I have also tried:

player = Manager.createPlayer("file:///Media Card/Blackberry/videos/I66.3GP");

 

This is also giving the same "invalid media file" error.

 

So how to access the media file correctly???? Please advise.

New Developer
Posts: 6
Registered: ‎10-23-2009
My Device: Not Specified

Re: Play video works on simulator, but not on phone

Problem Solved!! Turns out the "IoException: Cannot access media file" is because the BB is hooked up to the computer via USB, apprently Media Card is not accessible when USB is hooked up.

 

However, when USB is removed, I get this error:

java.lang.IllegalArgumentException: arg must not be null and must be a javax.microedition.lcdui.Canvas

Turns out that the BB audio/video tutorial is incorrect, initDisplayMode cannot accept "GUIControl", it can only accept Canvas. Also, if we directly pass in Canvas without instantiating it, it will also caused an IllegalArgumentException.

 

So here's the code that works:

 

 

VideoControl vc;

Canvas canvas = new MyCanvas( );

if ((vc = (VideoControl) player.getControl("VideoControl")) != null) {

vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, canvas);

vc.setDisplayLocation(15, 15);

vc.setDisplaySize(400, 400);

vc.setVisible(true);

 

 

 

player.start();

 

 

}

While MyCanvas( ) is a dummy class that extends javax.microedition.lcdui.Canvas

 

import javax.microedition.lcdui.Canvas;

import net.rim.device.api.ui.Graphics; 

 

class MyCanvas extends Canvas { 

public

 

public MyCanvas() {

}

 

protected void paint(javax.microedition.lcdui.Graphics arg0) {

// TODO Auto-generated method stub

}

}