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

Web and WebWorks Development

Reply
Contributor
Posts: 34
Registered: ‎11-01-2010
My Device: Torch 9800

Audio Extension ; what is the path to .mp3 file?

Hello!

 

I'm using Audio Extension to play sample.mp3 file. This file is stored inside folder [audio] within my app. Here is the code I used and it didn't work

 

var playerInstance = new  blackberry.audio.Player("file///audio/sample.mp3");

playerInstance.play();

 

I'm not sure if "file:///audio/sample.mp3" is the right path to use because it didn't work on simulator/device. Please help

 

Thanks

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300

Re: Audio Extension ; what is the path to .mp3 file?

give this a try and post up the results.

 

 

var playerInstance = new  blackberry.audio.Player("audio/sample.mp3");

playerInstance.play();

 

If it's packaged with your WebWorks application, I think that may work.

 

_________________________________________
www.jasonmace.com/blackberry
Contributor
Posts: 34
Registered: ‎11-01-2010
My Device: Torch 9800

Re: Audio Extension ; what is the path to .mp3 file?

Thanks! I've tried that but it didn't work. Can Simulator plays audio or do I have to test my app on device to get sounds?

Contributor
Posts: 12
Registered: ‎10-06-2010
My Device: Not Specified

Re: Audio Extension ; what is the path to .mp3 file?

Shouldn't it be "local:///audio/sample.mp3"?


www.lionbridge.com
New Developer
Posts: 3
Registered: ‎07-29-2010
My Device: BlackBerry Bold 9000

Re: Audio Extension ; what is the path to .mp3 file?

[ Edited ]

If you're using files in your widget you'll need to use the local URI and content type. 

 

Example:

 

 

var playerInstance = new  blackberry.audio.Player("local:///mp3/sound2.mp3","audio/mpeg", true);
playerInstance.play();

 

 

 

First parameter is the URI string (local is relative to your application).

Second is the content-type (see content type example http://www.blackberry.com/developers/docs/widgetapi/).

Third parameter is to use async or not for playback.

 

That should work! I didn't test audio on simulator, but works on my Bold.

 

---------------------------------------------------------------------------------
Windows 7 64 bit
Eclipse IDE Build id: 20090920-1017
BlackBerry Web Plug-in: 2.0.0.201003191451-33
BlackBerry Widget SDK: 1.0.0.201003191451-126
BlackBerry Smartphone Simulator: 2.13.0.95