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

Adobe AIR Development

Reply
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: MediaPlayer Error

Where is this sample.mp4 file.

If it is in your application  use applicationDirectory insteed of userDirectory .

If it is in your applicationstorage directory use applicationStorageDirectory insteed of userDirectory .

If it is in your documents directory use documentsDirectoy insteed of userDirectory .

 

Dont use file:// like this. first access your file. if <file obj>.exists is true then add file:// to file native path & pass it to media player URL object.

You can use my code snippet

var myFile : File= File.documentsDirectory.resolvePath(sourceAudioFile.name);
_myPlayer = new MediaPlayer();
_myPlayer.reset();
_myPlayer.url="file://" + myFile.nativePath;
_myPlayer.play();

 

 I hope this can help you. its working perfectly on my App.

 

 

 

New Contributor
Posts: 5
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: Giffgaff

Re: MediaPlayer Error

Hi,

Many thanks for this.  My code now looks like this:

 

_myVD =new VideoDisplay(false);

_myVD.setPosition(1024/2 - 640/2, 600/2 - 360/2);

_myVD.setSize(640, 360);

_myVD.backgroundColor = 0x000000;

addChild(_myVD);

 

var myFile : File= File.applicationStorageDirectory .resolvePath("sample_mpeg4.mp4");

_myPlayer =new MediaPlayer();

_myPlayer.videoDisplay = _myVD;

_myPlayer.reset();

_myPlayer.url="file://" + myFile.nativePath;

_myPlayer.play();

 

 

 

my mpg file sits in the bin debug folder, I've attached a screen greab as I'm really not sure I'm putting this in the right place.  Many thanks

 

Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: MediaPlayer Error

You dont need to put your file , in bin-debug folder , all data in  your assets folder will impleicitly copied to bin-debug folder , once you compile your code.

put your video file into src->assets folder..

_myVD =new VideoDisplay(false);

_myVD.setPosition(1024/2 - 640/2, 600/2 - 360/2);

_myVD.setSize(640, 360);

_myVD.backgroundColor = 0x000000;

addChild(_myVD);

 

var myFile : File= File.applicationDirectory .resolvePath("assets/sample_mpeg4.mp4");

_myPlayer =new MediaPlayer();

_myPlayer.videoDisplay = _myVD;

_myPlayer.reset();

_myPlayer.url="file://" + myFile.nativePath;

_myPlayer.play();

 And use this code to run it.

New Contributor
Posts: 5
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: Giffgaff

Re: MediaPlayer Error

Great , thank you this worked!  It's now playing video on my playbook, however it's still not playing it on the Playbook simulator for some reason, still giving the same error, which is annoying as I was intending to demo it to people on my machine, however it's playing on the playbook which is the main thing.  Many thanks for the help

Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: MediaPlayer Error

[ Edited ]

I am Glad that i can be able to help you.

If you feel you got your desired answer , close this thread by acceting Answer

Thanks & cheers.

New Contributor
Posts: 5
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: Giffgaff

Re: MediaPlayer Error

[ Edited ]

Hi, One other issue, I'm having, nowthat the video is playing, the play/pause toggle is working, but the scrub/seek bar is not moving as the video plays and also doesn't seem to be grabbable, I have this code:

 

_myMediaControl.setOption( MediaControlOption.SEEKBAR,true );

 

Just wondering if anyone else has experienced this?

 

Also, I will happily accept the answer but where do I do this action?  I can't see any option to do this in the "options" tab

Highlighted
Developer
Posts: 172
Registered: ‎01-17-2011
My Device: 9500 series
My Carrier: Airtel

Re: MediaPlayer Error

HI

Ya seek bar option willnot work , Because before changing your media URL options, you are again initialiging media player object , by which it will lost its media player listener. you ned to again add event listener like seek chang listener.

Thanks