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 Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified
Accepted Solution

ControlledAccessException while playing audio in background thread

I have a system module that is a background thread, which plays one of the pre-installed ringtones on the device. It works excellent in the simulator, but on my actual device (8320, 4.5.0.81, Tmobile), a ControlledAccessException is being thrown, and of course, does not play the audio.

 

The application is code signed, and I've tried setting all the permissions of the application to 'Allow', and nothing worked.

 

The code fragment below is where the exception appears to be happening:

 

 

Player p = javax.microedition.media.Manager.createPlayer("file:///store/samples/ringtones/Alarm_EarlyRiser.mp3); p.realize(); p.prefetch(); p.start();

 

I was hoping one of the RIM folk (or anyone else) could point me in the right direction as to why this is occuring and how to solve this issue.

 

Thanks

 

 

Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

i also wanted to know if the BlackBerry OS restricts some access or functionality from background threads.
Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

... or does anyone have a link or an example showing a background thread playing audio.
Please use plain text.
Developer
kzettel
Posts: 120
Registered: ‎07-16-2008
My Device: 9000

Re: ControlledAccessException while playing audio in background thread

How are you creating a background thread?  Is it an actual thread or on some sort of system listener?
Kurt Zettel | Chief Architect | Metova
www.metova.com
Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

it's a thread that is started as a system module that runs in the background. It's started within the main() from an extended Application class.

 

something like this

 

 

... public static void main(String []args){ BackgroundClass bc = new BackgroundClass(); bc.enterEventDispatcher(); } ------------------- public class BackgroundClass extends Application{ public BackgroundClass(){ BackgroundThread bt = new BackgroundThread(); bt.start(); } } -------------------- public class BackgroundThread extends Thread{ public void run(){ ...code that tries to play audio... } }

 

 

 

Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

one thing I did notice is that the media files are Forward Locked. I also stumbled upon the ExtendedFileConnection interface.

 

From reading a few things...it appears that the files are encrypted, and i'm assuming i need to decrypt them in order to successfully play the files.

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

Re: ControlledAccessException while playing audio in background thread

I didn't notice when I originally read this thread but you are trying to play a RIM preloaded file.  I have seen the same error and it appears to have something to do with accessing RIM's secure content store.  I do not know a work around besides using your own sound files.  You could try opening the file manually with a read-only connection and passing the inputStream to the media player.  That may allow it to play nicely with your application.
Kurt Zettel | Chief Architect | Metova
www.metova.com
Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

I think i may have tried that and it didn't work, but i'll give it a try tonight. I saw another similar post where it was said that you cannot access the pre-installed media files.

 

Please use plain text.
New Developer
wigwam
Posts: 10
Registered: ‎01-06-2009
My Device: Not Specified

Re: ControlledAccessException while playing audio in background thread

okay..got official word from devsupport@rim.com:

 


"It is not programmatically possible for other applications to read any of the pre-installed media files as they are DRM encrypted "

 

 So that answers that.

Please use plain text.