Search code examples
phpjqueryjplayer

jPlayer does not cache the media while playing, if output is provided by PHP script


In other words: it does not cache rest of the song while it's playing.

JS:

$('#jplayer-9999').jPlayer({
    ready: function() {
        $(this).jPlayer('setMedia', {
            oga: 'http://mysite/getogg.php',
        }).jPlayer('play', 15);

        $(this).bind($.jPlayer.event.timeupdate, function(event) {
            if(event.jPlayer.status.currentTime > 55) {
                $(this).jPlayer('play', 15);
            }
        });

    },
    play: function() {
        $(this).jPlayer('pauseOthers');
    },
    cssSelectorAncestor: '#jp_container_9999',
    swfPath: '/js/jplayer',
    supplied: 'oga',
    preload: 'auto'
});

PHP (getogg.php):

<?php

header('Content-type: audio/ogg');
$output = readfile("/oggs/1234.ogg");

echo $output;

?>

However direct links work just fine and song is caching: oga: 'http://mysite/oggs/1234.ogg'

Please help resolving this issue.


Solution

  • The issue was related to OGG format. Changing media to MP3 fixed an issue.