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 Contributor
Posts: 6
Registered: ‎03-12-2010
My Device: Blackberry Bold 9700
My Carrier: Rogers

Beginner: Getting currently playing media

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/index.html and it seems that I cannot see a way to get the media from the media player. I have looked at net.rim.device.api.media and net.rim.plazmic.mediaengine.

 

Can someone point me to the right direction for this? Thanks.

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Beginner: Getting currently playing media

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

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800367/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Regular Contributor
Posts: 61
Registered: ‎08-15-2010
My Device: Z10
My Carrier: T-Mobile Germany

Re: Beginner: Getting currently playing media

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?

Regular Contributor
Posts: 61
Registered: ‎08-15-2010
My Device: Z10
My Carrier: T-Mobile Germany

Re: Beginner: Getting currently playing media

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 Smiley Sad.

Blackberry-EmptyContexts.JPG

 

Highlighted
Regular Contributor
Posts: 61
Registered: ‎08-15-2010
My Device: Z10
My Carrier: T-Mobile Germany

Re: Beginner: Getting currently playing media

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.

Regular Contributor
Posts: 61
Registered: ‎08-15-2010
My Device: Z10
My Carrier: T-Mobile Germany

Re: Beginner: Getting currently playing media

[ Edited ]

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.

Regular Contributor
Posts: 61
Registered: ‎08-15-2010
My Device: Z10
My Carrier: T-Mobile Germany

Re: Beginner: Getting currently playing media

BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Beginner: Getting currently playing media

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker