- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am facing the issue of the audio not being played from the installed App in the Mobile.
I am able to play the audio in the XDK Emulator but not in the Mobile.
The Error in the App Mobile App is code : 1 message : undefined
Here is the code
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
var my_media = null;
function playAudio(src) {
my_media = new Media(src, onSuccess, onError);
my_media.play();
}
function onSuccess() {
console.log("playAudio():Audio Success");
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
</script>
</head>
<body>
<h3>Luger</h3>
<button onclick="playAudio('www/Shot.ogg');"> <img src="Luger.jpg" width="500" height="200"> </button
I used both Wav and Ogg, both are playing fine in the Emulator not in the Installed App
Please Help if possible, Thanks in Advance
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Which plugin are you using?
Emulator is just a simulator. There are some limitations just check out this link: https://software.intel.com/en-us/xdk/docs/dev-emulator
Try to build with crosswalk and use either build or debug tab to see the actual behavior of the app.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all you can take look of one of our sample to understand how it works.
Here is the link: https://github.com/gomobile/sample-audio-player
.wav and .ogg files are the only ones compatible with the emulator. However, you can use .mp3 files without issues except that you should test on a built app or app preview.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Amrita,
Thanks for your Example, but I think I figured out the problem here.
The issue is happening if the Sound File is present Locally in the www folder, If I give a Sound File URL to be played instead, it is getting played flawlessly in the App .
In your given example, the Cordova API Function has an URL for its playback, so its getting played both in the Emulator and the App.
I think the issue is with the Asset Compression in Android and the MP3 did not get compressed correctly.
I am adding the changed code
<body>
<h3>Luger</h3>
<button onclick="playAudio('http://www.wolfensteingoodies.com/archives/olddoom/sounds/dspistol.wav');"> <img src="Luger.jpg" width="500" height="200">
Thanks for your time again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great! I am glad it is working

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page