当前位置:网站首页>Google browser realizes video playback acceleration function

Google browser realizes video playback acceleration function

2020-11-06 21:45:33 Architects who can drive

chrome Browser console creation js Script and execute
Chrome Of snippets It's a little script , You can also create and create in Chrome DevTools In the source panel of the . You can access and run them from any page . When you run a clip , It is executed from the context of the currently open page . This article mainly talks about how to use , And complete a page auto refresh function .

First step

First f12 Open developer tools , And on again Sources The palette , Click on Snippets tab , Right click in navigator , And then choose New.

The second step

Enter the code in the editor . When you have unsaved changes , Next to your script name is “*”, Like the screenshot below . Press Command+S(Mac) or Ctrl+S(Windows and Linux), To save changes .

The third step is to run your code fragment

There are three ways :
1、 In the fragment file name ( All the clips are listed in the left pane ) Right click and select “RUN”.
2、 Click the run button ().
3、 Press Command+Enter(Mac) or Ctrl+Enter(Windows and Linux).

for example : Speed up the video playback function to achieve .

// Speed up the playback
document.getElementById(“tcPlayer_html5_api”).playbackRate = 3

// The space bar controls playback
document.onkeyup = function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
var obj = document.getElementById(“tcPlayer_html5_api”);
if (e && e.keyCode == 32) {
obj.paused === true ? obj.play() : obj.pause();
return false;
} else if (e && e.keyCode == 37) {
obj.currentTime !== 0 ? obj.currentTime -= 20 : 1;
return false;
} else if (e && e.keyCode == 39) {
obj.currentTime !== obj.duration ? obj.currentTime += 20 : 1;
return false;
} else if (e && e.keyCode == 38) {
obj.volume <= 0.9 ? obj.volume += 0.1 : 1;
return false;
} else if (e && e.keyCode == 40) {
obj.volume >= 0.1 ? obj.volume -= 0.1 : 1;
return false;
}
};

版权声明
本文为[Architects who can drive]所创,转载请带上原文链接,感谢