0
votes

i have html5 audio player like play, pause, stop buttons.

function onUpdate()
{
    var isPlaying = (!getAudioElement().paused);
    document.getElementById("playerplay").style.display = (isPlaying)?"none":"block";
    document.getElementById("playerpause").style.display = (isPlaying)?"block":"none";
};

function getAudioElement()
{
    return document.getElementById("id_audio_element");
}

function play() {
    getAudioElement().play();
    onUpdate();
}

function pause() {
    getAudioElement().pause();
    onUpdate();
}

function stop() {
    getAudioElement().pause();
    getAudioElement().currentTime=0;
    onUpdate();
    getAudioElement().load();
}

And audio tag:

<audio id="id_audio_element" onended="onUpdate();load();"><source src="105.ogg" type="audio/ogg"></audio>

it works all on browsers perfectly, exept iPhone and iPad's Safari and Chrome. When I call load() , audio starts playing, although I don't call play().

Anybody has a solution? Thanks!

1

1 Answers

0
votes

If the source is not changing, there is no need to call load(). If it is changing, try calling pause() after it loads.