Software Archive
Read-only legacy content
17061 Discussions

How to Play Media mp3 Offline Intel XDK?

Adam_Suchi_Hafizulla
344 Views

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. :)

 

0 Kudos
1 Solution
PaulF_IntelCorp
Employee
344 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

0 Kudos
2 Replies
PaulF_IntelCorp
Employee
345 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.

0 Kudos
Adam_Suchi_Hafizulla
344 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 :)

0 Kudos
Reply