I know its a repeated questions but I cannot figure out how to do in my case. I want to play audio using JS Buzz library. Please check following
var pg1 = new buzz.sound("oimages/music/as.mp3");
var pg2 = new buzz.sound("oimages/music/zx.mp3");
var pg3 = new buzz.sound("oimages/music/as.mp3");
On a certain event I want to play this audio. here 1, 2 and 3 are page numbers. Please check following
$("#flipbook").bind("turned", function (event, page, view) {;
bog ='pg'+page; // page is the number of page here
window.bog.play(); //error
});
It gives me following error
Uncaught TypeError: window.bog.play is not a function
Please guide.
Because
bog ='pg'+page;
is a string, not a reference to the sound file.You need to reference the sound assuming they are in global scope you can use bracket notation