jplayer how to display “buffering” text

谁都会走 提交于 2019-12-02 08:27:19

问题


i have a question about jplayer.

this is my code:

$("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                title: "Alin",
                artist: "song",
                mp3: "utl"
            });
        },
        solution: 'html, flash',
        cssSelectorAncestor: "#jp_container_1",
        swfPath: "/res/vendor/jPlayer/dist/jplayer/",
        supplied: "mp3",
    });

    $("#jquery_jplayer_1").bind($.jPlayer.event.seeking, function(e){
        if($(".jp-title span").length <= 0){
            $(".jp-title").prepend('<span><i class="fa fa-refresh fa-spin"></i></span>');
        }
    });

    $("#jquery_jplayer_1").bind($.jPlayer.event.seeked, function(e){
        $(".jp-title span").remove();
    });



    $("#jquery_jplayer_1").bind($.jPlayer.event.timeupdate, function(e) {
        if (this.value === 0 ){
            alert(1);
        }
    });

I want to show "Buffering" text if the playing music paused due slow internet. Actually i want to catch event when a playing audio is being paused for short while for buffering and then automatically play again when enough data buffered.

like this:

thanks


回答1:


$("#jquery_jplayer_1").bind($.jPlayer.event.progress, function (event){
   // If media loading is complete
   if (event.jPlayer.status.seekPercent === 100){        
     $(".jp-title .jp-title-loading").remove();

   // Otherwise, if media is still loading
   } else {
       if($(".jp-title .jp-title-loading").length == 0){
          $(".jp-title").prepend('<div class="jp-title-loading">Loading...</div>');
       }
    }
});


来源:https://stackoverflow.com/questions/30123390/jplayer-how-to-display-buffering-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!