4

I am having a playlist of mp3s in my website. When you click play the first song starts and when it is done it plays the next one until the playlist is over.

Everything works fine in Chrome but in Safari 7 ( Mavericks ) if the tab is not on focus after the first song finishes the second is not started until I focus the tab.

my code looks like this:

function play( song_path ){
    var html = ""+ 
        '<audio id="html_player" controls autoplay>' +
        '   <source src="'+ song_path + '" type="audio/mpeg">'+
        '</audio>';
    $("#player_element").html( html );  
    var song = $("audio")[0];
    song.play();

    $(song).on('ended', function() {
       playNext();
    });
}

the function playNext() gets the url of the next song and calls play( new_url ).

Any ideas how to overcome this problem ?

gotha
  • 489
  • 1
  • 5
  • 20
  • This thread might help you out: http://stackoverflow.com/questions/11170228/changing-source-with-html5-audio-works-in-chrome-but-not-safari?rq=1 – izaic3 Nov 25 '13 at 10:41
  • if the tab is open or if the page is opened in separate Safari window ( even if the window is not visible) everything works as expected. So the problem is not with changing the source of file. I suspect this is somehow related to Apple`s power saving options and/or optimizations – gotha Nov 25 '13 at 15:50

0 Answers0