Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
kcheng86
Posts: 7
Registered: 09-22-2009

problem invoking media content handler repeatedly

Hi,

 

I need to be able to play different files for user to view  (audio or text) using content handler but there is some problem. my environment is

 

Blackberry 9000, v4.6.0.162.  Component pack 4.6.1

 

the code is :

 

 

 

 

 

 

 

 

 

 

 

Invocation invocation =

new Invocation(uri, null

,

BlackBerryContentHandler.

ID_MEDIA_CONTENT_HANDLER

);

 

 

// Get the registry object

Registry registry = Registry

.getRegistry(

"aw.myproject.screens.TaskDetailsScreen"

);

 

 

 

try

{

 

boolean

result = registry.invoke(invocation);

Logger.getLogger().debug(

 

"invocation " + invocation.getURL() + " result "

+ result);

}

catch (IllegalArgumentException e) {

Logger.getLogger().error(

"invocation error "

+ e.getMessage());

 

}

catch  (ContentHandlerException e) {

Logger.getLogger().error(

"invocation error "

+ e.getMessage());

 

}

catch  (SecurityException e) {

Logger.getLogger().error(

"invocation error "

+ e.getMessage());

 

}

catch  (IOException e) {

Logger.getLogger().error("invocation error "  + e.getMessage());

 

}

catch  (Exception e) {

Logger.getLogger().error(

"invocation error "

+ e.getMessage());

}

 

What happens is:

 

When I call this code to play some file for the first time, everything works, a media player instance shows up and plays the file. 

 

Now if I close the media player instance with the escape button, and call the same code again for a different file it also works fine, just as the first time.

 

Now if I leave the media player instance open, switch to home screen and open my user application again and choose the play another file with the above code, I can see the screen switch to the media player instance very shortly then switch back to my app, file is not played.   This other file is valid as I could still use media player application to navigate to the file location and play it.

 

please help with my problem to play another file.

Thanks

 

 

Please use plain text.
New Contributor
BBinIdaho
Posts: 8
Registered: 02-06-2010
My Carrier: Verizon

Re: problem invoking media content handler repeatedly

I had the exact same problem trying to play an mp3 file -- very frustrating. But I found you can get around this by playing audio in the browser. Here's an example using an audio file pre-installed in OS 4.5:

 

BrowserSession soundclip = Browser.getDefaultSession();
soundclip.displayPage("file:///store/samples/ringtones/Alarm_Antelope.mid");

 

All the bugs with trying to close the player using the excape key, and then trying to play audio again, seem to be gone. Hope that helps.

 

Please use plain text.
Regular Contributor
vedernikov
Posts: 67
Registered: 09-30-2009

Re: problem invoking media content handler repeatedly

Thanks you, BBinIdaho - that really helped.

Although this approach is suggested in BB multimedia guide - this solution has totally fallen out of my head - thanks for reminding

Please use plain text.