03-12-2010 03:32 PM
Hi, I'm new to the BlackBerry application development world and for my first small app, I need to get the currently playing media in the built-in BlackBerry media player. Maybe as an object or the song title, whatever's possible.
I have looked through the documentation found here: http://www.blackberry.com/developers/docs/5.0.0api
Can someone point me to the right direction for this? Thanks.
03-15-2010 12:54 PM
There is no BlackBerry API that would allow you to obtain the media currently being played in the built in media player. Applications are able to play back their own media files. You can also add a menu item into the media services area of the media application using the ApplicationMenuItem and ApplicationMenuItemRepository classes. You can find an example of the user of these classes here:
How To - Add a custom menu item to an existing BlackBerry application
12-26-2010 08:24 PM
MSohm, thank you for a helpful link and the explanation.
However, I could not find a way to get the current song file name when using the proposed method.
Following the link you have posted I recon that the MENUITEM_MUSIC_SERVICE_ITEM field of the ApplicationMenuItemRepository corresponds to the BB MediaPlayer app. Unfortunately, the API reference does not mention, what type of the Object will be passed to the ApplicationMenuItem.run(Object) method. In case of other fields like MENUITEM_FILE_EXPLORER a String instance (the path to the file) is passed.
Do you know how to handle the Object in question for the MediaPlayer or where to get this information?
12-28-2010 08:08 AM
Here I have quckly hacked together a small test to see if I could see in the debugger what object is being returned.
public HelloWorldDemo()
{
MyMenuItem myMenuitem = new MyMenuItem(0);
ApplicationMenuItemRepository
.getInstance().addMenuItem
(ApplicationMenuItemRepository
. MENUITEM_MUSIC_SERVICE_ITEM ,myMenuitem);
// Push a screen onto the UI stack for rendering.
pushScreen(new HelloWorldScreen());
}
class SongName {
private static String song;
public static String getString () {return song; };
public static void setString(String songName) { song=songName; };
}
class MyMenuItem extends ApplicationMenuItem{
//using the default constructors here.
MyMenuItem(int order){
super(order);
}
//methods we must implement
//Run is called when the menuItem is invoked
public Object run(Object context){
//HERE I PUT THE BREAKPOINT TO SEE THE context Object.
//context object should be a song or something
// in fact an empty string comes out for the SongName
SongName.setString( (String)context) ;
return context;
}
//toString should return the string we want to
//use as the label of the menuItem
public String toString(){
return "Rate This Song";
}
}
But unfortunately it seems just an empty object is being retunred as a "context". Please tell me I'm wrong, 'cause it's just too sad if this api for mediaplayer is not implemented by RIM at all
.
12-28-2010 09:31 AM
I recall that Blackberry messenger has an option to "show what I'm listening to". What is the mechanism to get the song info for the messenger then? Is it an undocumented api? Is it possbile to get it into the official api too?
Hope after the winter holidays somebody from RIM could comment on these questions.
01-01-2011 06:55 AM - edited 01-01-2011 10:32 AM
This supportforums thread has a link to the video demo of a requested behaviour. How did the developers of the "Twit this Blaq" get the song name? Here is the description of this feature from their page.
01-07-2011 07:29 PM
01-11-2011 02:19 PM
Currently there is no API in the BlackBerry API set that provides the song currently be played in the BlackBerry Media Player.
The application you refer to may be scraping the text from the screen of the media, but this is not something we support.