If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Developer
stefano
Posts: 51
Registered: ‎08-07-2008
My Device: Not Specified
Accepted Solution

Play a file from SDCard

I've problems to play a file from sdcard. I looked EmbeddedMediaDemo sample and I changed the line:

 

            //InputStream is = getClass().getResourceAsStream("/media/BlackBerry.mp4");
            InputStream is = getClass().getResourceAsStream("/SDCard/BlackBerry/videos/VID00019.3GP");

 

and I receive the message :" Uncaught exception stream : null"

I tried also so:

            InputStream is = getClass().getResourceAsStream("file:///SDCard/BlackBerry/videos/VID00019.3GP");     

 but same problem

 

 

I try to include  VID00019.3GP into the proj, then use this line:

              InputStream is = getClass().getResourceAsStream("/media/VID00019.3GP");

it work.

 

 

please help-urgent.

thanks

 

 

 

 

 

 

 

Please use plain text.
Developer
jiggak
Posts: 28
Registered: ‎07-24-2008
My Device: Not Specified

Re: Play a file from SDCard

Instead of creating an input stream, just pass the URI of the file to Manager.createPlayer

 

_player = javax.microedition.media.Manager.createPlayer("file:///SDCard/BlackBerry/videos/VID00019.3GP"); _player.addPlayerListener(this); _player.realize();

 

 

 

Please use plain text.
Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: Play a file from SDCard

Passing the uri is the easiest way.  You can open an input stream from the file system using the FileConnection:

 

 

InputStream inputStream = null; FileConnection fileConnection = (FileConnection) Connector.open( "file:///SDCard/BlackBerry/videos/VID00019.3GP"); if (fileConnection.exists()) { inputStream = fconn.openInputStream(); }

 

 

 

Kurt Zettel | Chief Architect | Metova
www.metova.com
Please use plain text.
Developer
stefano
Posts: 51
Registered: ‎08-07-2008
My Device: Not Specified

Re: Play a file from SDCard

Thanks, work
Please use plain text.