上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖
楼主: vinian - 

【某干部学习网】求助分析一下

[复制链接]

该用户从未签到

1

主题

0

回帖

3

积分

助理工程师

积分
3
发表于 2022-4-27 21:58:54 | 显示全部楼层 | 阅读模式
悬赏1油猫币未解决

想写个脚本秒刷视频的。我感觉控制时长的代码应该在这里面,我是小白求大神帮助。

if (typeof(player) == "undefined")
player = new Object();
player.player_time = 0;
player.hide = 0;
player.src;
player.duration;
player.currentIndex = 0;
player.otherClips=true;
player.init = function () {
player.switchClarity(player.clarity_id);
var video=$("#" + player.player_id);
video[0]['disablePictureInPicture']=true;//去掉画中画
$("#" + player.player_id).bind("ended", function () {
//player.play(curr);

    if(switchPlayList.length==1||curr >= switchPlayList.length){
        $("#"+player.player_id)[0].pause();

    }else{
        player.play(curr);
    }

})

};
setInterval(function(){
if(player.getState()==3)
player.player_time++;
},1000);

player.getSrc = function(){
return player.src;
}
player.setSrc = function(src){
player.src = src;
}

player.realy = function(){
return $("#"+player.player_id)[0].readyState == 4;
}
player.play = function (stat) {
if (typeof(stat) == "undefined"||"number") {
//$("#"+player.player_id)[0].play();
videoPlay(stat);

}else{
    $("#"+player.player_id)[0].pause();
}

};

function videoPlay(i){
// $("#"+player.player_id).attr("src",switchPlayList[i].url);

    if($("#course_player")){
        var videoTag="<video id='course_player' width='640px' height='360px'  controls='controls' controlsList='nodownload' preload='preload' oncontextmenu='return false;'>"+
            "\u60a8\u7684\u6d4f\u89c8\u5668\u7248\u672c\u8fc7\u4f4e\uff0c\u8bf7\u4f7f\u7528\u0049\u0045\u0039\u4ee5\u4e0a\u6216\u8005\u652f\u6301\u0048\u0054\u004d\u004c\u0035\u7684\u6d4f\u89c8\u5668\u3002</video>";
        $("#video_box").empty();

    }
    $("#video_box").append(videoTag);
    player.init();
    $("#"+player.player_id).attr("src",switchPlayList[i].url);
    player.currentIndex=i;
    $("#"+player.player_id)[0].load();//若视频很短,加载完后再播放,监听canplaythrough事件即可
    $("#"+player.player_id)[0].play();

    //选中当前菜单
    var id = switchPlayList[i].id;
    $(".first_list li").removeClass("current");
    $(".first_list li[id='" + id + "']").addClass("current");
    $(".first_list>li").find("b").css("background", "url(imgs/chapter.png) no-repeat").parent("li.current").find("b").css("background", "url(imgs/chapter_active.png) no-repeat");
    if (i< switchPlayList.length) {
        i++;
    }else{
        i=0;
        $("#"+player.player_id)[0].pause();
    }
    curr=i;

//切换清晰度时从播放点续播
if(claritySwitch){
    player.setPosition(switchClipTime);
    claritySwitch = false;
}
//从断点处继续播放
if (player.otherClips) {
    var now_clip = breakPoint();
    var now_play = now_clip.split(".");
    if (now_play[0] == "" || now_play[0] == undefined) {
        now_play[0] = 0;
    }
    player.setPosition(parseInt(now_play[0]));
    player.otherClips = false;
}

}
player.switchClarity=function (i){
switch(i){
case 1:
switchPlayList =chapter.playlistH;
break;
case 2:
switchPlayList =chapter.playlistM;
break;
case 3:
switchPlayList =chapter.playlistL;
break;
}
return switchPlayList;

};

player.stop = function (stat) {
if(player.realy()){
player.setPosition(0);
player.play(false);
}
};
player.getState = function () {
var netState = $("#"+player.player_id)[0].networkState;
var readyState = $("#"+player.player_id)[0].readyState;
if(netState == 0){
return -1;
}else if(!$("#"+player.player_id)[0].paused){
return 3;
}else if($("#"+player.player_id)[0].paused){
return 4;
}else if($("#"+player.player_id)[0].paused&&$("#"+player.player_id)[0].currentTime == $("#"+player.player_id)[0].duration){
return 5;
}else if(netState == 1){
return 0;
}else if(netState == 3){
return 1;
}else if(netState == 2){
return 2;
}
};

player.getPosition = function () {
if(player.realy())
return Math.floor($("#"+player.player_id)[0].currentTime);
else
return 0;
};
player.setPosition = function (pos) {
//if(player.realy())
// $("#"+player.player_id)[0].currentTime = pos;
var video=document.getElementById(player.player_id);
video.addEventListener('loadedmetadata', function () {
video.currentTime = pos;
});

};
player.getRealTime = function () {
return player.player_time;
};
player.getDuration = function(){
//data.xml中定义的duration 与 真实视频的duration对比,取比较小的时长
var duration = Math.floor($("#"+player.player_id)[0].duration);
/if (duration!=null&&duration>0&&duration<player.duration) {
return duration;
}
/
return player.duration;
};

/player.continuePlay=function(){
var now_clip = pos;//breakPoint();
var now_play = now_clip.split(".");
if (now_play[0] == "" || now_play[0] == undefined) {
now_play[0] = 0;
}
player.play(parseInt(now_play[1]));
//player.setPosition(now_play[0])
}
/

  • TA的每日心情
    慵懒
    2024-10-28 07:07
  • 签到天数: 193 天

    [LV.7]常住居民III

    712

    主题

    5966

    回帖

    6764

    积分

    管理员

    非物质文化遗产社会摇传承人

    积分
    6764

    荣誉开发者喜迎中秋油中2周年生态建设者

    发表于 2022-4-28 00:32:51 | 显示全部楼层
    这种还是推荐哥哥学一下自己写...
    别人即使看代码也没啥用的
    混的人。
    ------------------------------------------
    進撃!永遠の帝国の破壊虎---李恒道

    入驻了爱发电https://afdian.net/a/lihengdao666
    个人宣言:この世界で私に胜てる人とコードはまだ生まれていません。死ぬのが怖くなければ来てください。
    回复

    使用道具 举报

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表