triceam / LowLatencyAudio

47 stars 25 forks source link

Following the Instructions, but failing somewhere #2

Closed wuuster closed 10 years ago

wuuster commented 10 years ago

So I did a lot of reading up on your plugin and I installed it via Terminal as instructed.

The installation was successful and my IOS Phonegap 3.0 app built with no errors.

  1. I added the javascript in the header of my HTML file like so

script type="text/javascript" src="cordova.js" script type="text/javascript" src="cordova_plugins.js" script type="text/javascript" src="js/LowLatencyAudio.js"

script document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { } /script

  1. And I added this to the body

    $('#btn').click(function() {

    LowLatencyAudio.preloadAudio('id', 'files/test.mp3', 1);
    
    LowLatencyAudio.play( 'id');

});

But the audio doesn't play. I really would like to use this plugin, hoping you can help

triceam commented 10 years ago

You need to preload the audio before you want to use it. The loading process is asynchronous. Load the audio assets in an initialization routine, then they will be ready when you want them. Calling them inline like you have it will try to invoke play before the asset has actually been loaded into memory.