Community
cancel
Showing results for 
Search instead for 
Did you mean: 
105 Views

How to Play Media mp3 Offline Intel XDK?

Jump to solution

Hi everyone. I want to ask how to play media *.mp3 offline in Intel XDK?

My code:

var src = "sounds/music.mp3";
var my_media = new Media(src,
               // success callback
               function () {
                   alert("playAudio():Audio Success");
               },
               // error callback
               function (err) {
                  alert("playAudio():Audio Error: " + err.code);
               });

my_media.play({playAudioWhenScreenIsLocked : true });

And i already put the mp3 file to www path.

path.png

And when i run project, i got error number "1". But when i change source file to streaming radio, its working, but for the offline music its not working. Im using Media plugins version 2.4.0 and Cordova CLI version 5.4.1.

Thank for your help. :)

 

Tags (2)
0 Kudos
1 Solution
PaulF_IntelCorp
Employee
105 Views

Check the "hello cordova" sample app to see how it plays back a local media file. Locating the media file will vary depending on the platform. And don't use alerts to debug your apps, they tend to interfere with your program logic, use console.log messages, instead, they are much less intrusive on the runtime thread of execution.

View solution in original post

2 Replies
PaulF_IntelCorp
Employee
106 Views

Check the "hello cordova" sample app to see how it plays back a local media file. Locating the media file will vary depending on the platform. And don't use alerts to debug your apps, they tend to interfere with your program logic, use console.log messages, instead, they are much less intrusive on the runtime thread of execution.

View solution in original post

105 Views

Paul F. (Intel) wrote:

Check the "hello cordova" sample app to see how it plays back a local media file. Locating the media file will vary depending on the platform. And don't use alerts to debug your apps, they tend to interfere with your program logic, use console.log messages, instead, they are much less intrusive on the runtime thread of execution.

 

Thank you Paul :)

Reply