Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
cfjedimaster committed Sep 9, 2016
1 parent d4e044d commit 2ab11cb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions loopingaudio/www/js/index.js
@@ -1,14 +1,17 @@
document.addEventListener('deviceready', init, false);
var media;
var isAndroid = false;

function init() {
console.log('init');
if(device.platform.toLowerCase() === "android") isAndroid = true;

media = new Media(getMediaURL('arcade1.mp3'), null, mediaError, mediaStatus);
media.play();
media.play({numberOfLoops:9999});
}

function getMediaURL(s) {
if(device.platform.toLowerCase() === "android") return "/android_asset/www/" + s;
if(isAndroid) return "/android_asset/www/" + s;
return s;
}

Expand All @@ -17,9 +20,8 @@ function mediaError(e) {
}

function mediaStatus(status) {
if(status === Media.MEDIA_STOPPED) {
if(isAndroid && status === Media.MEDIA_STOPPED) {
media.seekTo(0);
media.play();
}
console.log('status', JSON.stringify(arguments));
}

0 comments on commit 2ab11cb

Please sign in to comment.