views:

653

answers:

3

Like I said, the application has to call the default Blackberry media player.Does anybody know or maybe point in a direction to implement it

Enviroment : Eclipse+BB plugin 4.5

+2  A: 

There are two ways to do this.

The first approach would be to use the content handler mechanisms of the device. You'll essentially be forcing the device to deal with a given file in a default manner. For audio files, the default manner would be to launch the media player on the device with the file.

So, for example if you have a file called song.mp3 on the SD card on the device, you would do something like the following (code is from memory, haven't checked it in a while):

Invocation invocation = new Invocation("file:///SDCard/BlackBerry/music/song.mp3"); 
Registry reg = Registry.getRegistry("net.rim.device.api.content.BlackBerryContentHandler");
reg.invoke(invocation);

The second approach would be to use the content handler in the BlackBerry web browser to, essentially, accomplish the same thing. In the case of a browser, you can use the standard classes related to net.rim.blackberry.api.browser.BrowserSession to launch an instance of a browser with the URL to the music file. The URL can be something on the web, or, as above, it can be a file:// location on the device itself. This will cause the browser to deal with the content, which will essentially launch the music player and play the file.

Andrey Butov
thanks for the help.
AJPRA23
A: 

First option will not only on Simulators and not device. So don't go for that...

Vishal
this should be a comment, not an answer
mtmurdock
A: 

Sorry.... correcting above comments,

First option works only on Simulators not on device. So don't go for that...

Vishal
this should be a comment, not an answer.
mtmurdock