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

Adobe AIR Development

New Contributor
Posts: 4
Registered: ‎02-26-2012
My Device: Blackberry Playbook 16G, BB 9780
My Carrier: Rogers

MediaPlayerEvent.PREPARE_COMPLETE gets stuck for invalid URL


Whenever i have an invalid URL for the media player it gets stuck on MediaPlayerEvent.PREPARE_COMPLETE event and the whole app becomes unstable. App wont work without restarting the device. 

is the any way to handle the error for invalid URL;s ?


Code : 


_myPlayer.url = "";
_myPlayer.addEventListener(MediaPlayerEvent.PREPARE_COMPLETE, CompleteEvent);
lable.text = "Connecting Media";

catch (e:Error)
lable.text = "Catch Error"+ e.toString() ;
_myPlayer.removeEventListener(MediaPlayerEvent.PREPARE_COMPLETE, CompleteEvent);

Posts: 427
Registered: ‎02-22-2012
My Device: BlackBerry Z10, BlackBerry Dev Alpha C, BlackBerry PlayBook
My Carrier: Bell

Re: MediaPlayerEvent.PREPARE_COMPLETE gets stuck for invalid URL

Have a look at INFO_CHANGE.


"Dispatched to communicate some information and/or a warning about the media or its playback."


For samples on how to use it have a look at the API documentation here - https://developer.blackberry.com/air/apis/qnx/media/MediaPlayer.html#event:infoChange



If that doesn't work I was thinking maybe checking to see if the file exists before trying to load it might solve the issue. I googled it and came across this - http://www.kirupa.com/forum/showthread.php?328651-Checking-to-see-if-a-file-exists-before-loading




Follow me on Twitter: @dustinmalik
Keep up to date on BlackBerry development: http://devblog.blackberry.com/