jPlayer獲取播放時間


關於jPlayer的用法,可以參考:jPlayer 2.6.0開發者手冊

http://www.jplayer.cn/developer-guide.html

 

視頻播放例子:

//視頻播放
var videoPlay = function(){
    $("#video").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                m4v: "http://n3-q.mafengwo.net/s9/M00/A9/D1/wKgBs1gan1qAG70PARSQeSbHDT8721.mp4"
            }).jPlayer("play");
            resizeVideo();
        },
        play: function(){
        },
        ended: function() {
            $(this).jPlayer("pause",1);
            $('.video_box').hide();
            $('.container').show();
            oHeader.css('display','block');
            $("html,body").animate({scrollTop:58},500,function(){
                $(".container .t-focus").addClass('current');
            });
        },
        timeupdate:function (e) {
            if(parseInt(e.jPlayer.status.currentTime) > 10) {
                $('.video_box .skip').css('display','block');
            }
            // console.log(parseInt(e.jPlayer.status.currentTime));
        },
        // size:{
        //     width: $(window).width() + "px",
        //     height: $(window).width() + "px"
        // },
        // sizeFull:{
        //     width: "100%",
        //     height: "100%",
        // },
        swfPath: '/swf',
        supplied: "m4v",
        solution: ("html,flash"),
        wmode: "window",
        backgroundColor:"#000000"
    });
}
//重置視頻大小
function resizeVideo(){
    var window_w = $(window).width() ;
    var window_h = $(window).height();

    var video_w = window_w;
    var video_h = window_h;
    if(window_w/window_h < 16/9){
        video_w = video_h*16/9;
    }else if(window_w/window_h > 16/9){
        video_h = window_w*9/16;
    }
    $("#video").jPlayer({
        // size:{
        //     // width: video_w + "px",
        //     height: video_h  + "px"
        // },
        fullScreen: true,
    });
}

 

獲取視頻播放時間(秒數)

 
         
e.jPlayer.status.currentTime
parseInt(e.jPlayer.status.currentTime)  轉為int類型
timeupdate:function (e) {
},

 

還有其他更多方法,請查看文檔。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM