Reputation: 63
I am using buzz.js library for html. I have a HTML list element where every list element has a specific audio. i want to play audio on click event of list and also on next and previous buttons. so i wrote below code for that, it's working on desktop browsers. when i am testing it on mobile safari (ipad1). when i am playing audio second time it is started from where it is stopped on last time. i want to start audio from beginning.
$(document).ready(function(){
var mainIntro = new buzz.sound( "audio/intro", {formats: [ "ogg", "mp3", "aac" ], preload: true, autoplay: true, loop: false});
var slide1 = new buzz.sound( "audio/slide1", {formats: [ "ogg", "mp3", "aac" ], preload: true, autoplay: true, loop: false});
function introAudio() {
buzz.all().stop();
mainIntro.play().bind('ended', function(e){
document.getElementById("blinkRed").style.visibility="visible";
});
}
function slide1Audio() {
buzz.all().stop();
slide1.play().bind('ended', function(e){
document.getElementById("blinkRed").style.visibility="visible";
});
}
$('#navHolder ul li a').click(function() {
if (myIndex == -1){
$('#slideHolder').attr('src',"introMain.html");
myIndex = -1;
introAudio();
}
else if (myIndex == 0){
$('#slideHolder').attr('src',"intro.html");
myIndex = 0;
slide1Audio();
}
else if (myIndex == 1){
}
});
Upvotes: -1
Views: 604
Reputation: 33
I know this is old, but it comes up on Google searches so I thought I would answer.
I had a similar problem like this before and to fix it you have to add a line of code. It only seems to happen in WebKit based browsers.
Add:
mySound.load();
This reloads the audio file and it starts from the beginning.
Upvotes: 0