HTML5 audio not playing in PhoneGap App (Possible to use Media?)

前端 未结 7 1059
执笔经年
执笔经年 2020-12-06 14:05

Working on a basic sound board for a trip abroad. Set up everything to work fine in Browsers but wanted to use PhoneGap Build/GitHub to make it downloadable as cell service

7条回答
  •  感动是毒
    2020-12-06 14:35

    Uff that was really hard and confusing ... But I finally did it!

    Here is exactly what i did:

    index.html

    
    
    

    AndroidManifest.xml

    
    
    
    

    index.js

    function playAudio(id) {
    var audioElement = document.getElementById(id);
    var url = audioElement.getAttribute('src');
    var my_media = new Media('/android_asset/www/' + url,
            // success callback
             function () { console.log("playAudio():Audio Success"); },
            // error callback
             function (err) { console.log("playAudio():Audio Error: " + err); }
    );
           // Play audio
    my_media.play();
    

    }

    plataform/android/res/xml.config

    
            
        
    

    And it finally works!!! :D uhuuuuu

提交回复
热议问题