javascript - Hybrid App: Audio not playing on Android -
i using monaca.mobi build hybrid app. when build app ios fine; however, when build android device (nexus 7) audio come through. in monaca debugger; however, audio works fine. there android devices not aware about, maybe permissions of app?
sound played through angularjs function called on button clicks. know code correct, thought might share it:
function dontask($scope){ $scope.play = function(){ var audio = new audio(); audio.src = 'sounds/donteventask.mp3'; audio.play(); }}
thanks insight.
your above code working ios. android, path local audio file not recognized. following code work both oses. i've tested built app too.
$scope.play= function(){ var os = navigator.platform; if (os=='iphone'){ var url = "sounds/donteventask.mp3"; } else{ var url = getphonegappath() + "sounds/donteventask.mp3"; } var my_media = new media(url, // success callback function() { console.log("playaudio():audio success"); }, // error callback function(err) { console.log("playaudio():audio error: "+json.stringify(err)); }); // play audio my_media.play(); }
Comments
Post a Comment