学习通切换播放(可设置倍速、静音)

声明:非原创,代码来源于网络

【F12→Console粘贴后回车】

 1 function playVideo(){
 2 let iframe=$("#iframe").contents().find("iframe").contents();
 3     let video=iframe.find("#video_html5_api")[0];//找到video对象
 4     if(video == undefined){
 5         console.log("没有找到视频播放器");
 6         return;
 7     }
 8     video.play();//播放
 9     video.muted=true;//静音
10  video.playbackRate=2;//倍速播放 此处2速率播放
11  let text=$(".ncells .currents .hideChapterNumber").text().trim();
12     var tid=window.setInterval(function(){
13         let ul=iframe.find(".ans-videoquiz-opts:visible");
14         if(ul){//有题目出现
15             iframe.find(".ans-videoquiz-opts input[value='true']").attr("checked",true);
16             iframe.find(".ans-videoquiz-submit").trigger("click");//ext-gen1045
17         }
18         if(video.ended){//视频播放完
19             console.log(text+"节已播放完")
20         if($(".ncells .currents .roundpointStudent").hasClass("blue")){
21 console.log(text+"节任务点已完成")
22 let curr=$('.ncells .jobCount').first().next();
23 if(curr==undefined){
24 console.log('课程已看完');
25 clearInterval(tid);
26 return;
27 }
28 curr.click();
29 let fun=curr.attr('href').substr(11);
30 eval(fun);
31 window.setTimeout(function(){
32 console.log("正在为你自动播放下一个视频");
33 clearInterval(tid);
34 playVideo();
35 },5000);
36 }
37         return;
38         }
39     }, 5000);
40 
41     $("div").onmouseout=function(){
42 video.play();
43 return true;
44 }
45 }
46 function start(){
47 let curr=$('.ncells .jobCount').first().next();
48 if(curr==undefined){
49 console.log('课程已看完');
50 clearInterval(tid);
51 return;
52 }
53 curr.click();
54 let fun=curr.attr('href').substr(11);
55 eval(fun);
56 window.setTimeout(function(){
57 playVideo();
58 },5000);
59 }
60 start();

 

 

注:对于鼠标移开界面,视频就暂停播放的解决方案:

F12→Elements→Event Listener→mousemove→window 选择remove

上一篇:单链表结构及链表反转操作java代码实现


下一篇:LeetCode 1652. 拆炸弹 模拟