当前位置:网站首页>谷歌浏览器实现视频播放加速功能
谷歌浏览器实现视频播放加速功能
2020-11-06 21:45:00 【会开车的架构师】
chrome浏览器控制台创建js脚本并执行
Chrome的snippets是小脚本,还可以创作并在Chrome DevTools的来源面板中执行。您可以访问和从任何页面运行它们。当你运行一个片段,它从当前打开的页面的上下文中执行。本文主要讲如何使用,并完成一个页面自动刷新的功能。
第一步
首先f12 打开开发者工具,再打开Sources面板中,单击上Snippets选项卡,在导航器中单击鼠标右键,然后选择New。
第二步
在编辑器中输入代码。当你有未保存的更改,您的脚本名称旁边有“*”,像下面的截图。按Command+S(Mac)或Ctrl+S(Windows和Linux),以保存更改。
第三步运行你的代码片段
有三种方式:
1、在片段文件名(在左侧窗格中列出了所有的片段)右键单击并选择“RUN”。
2、点击运行按钮()。
3、按Command+Enter(Mac)或Ctrl+Enter(Windows和Linux)。
例如:视频加速播放功能实现。
// 加速播放
document.getElementById(“tcPlayer_html5_api”).playbackRate = 3
// 空格键控制播放
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;
}
};
版权声明
本文为[会开车的架构师]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4629483/blog/4529693
边栏推荐
- Read the advantages of Wi Fi 6 over Wi Fi 5 in 3 minutes
- Python basic variable type -- list analysis
- Vue communication and cross component listening state Vue communication
- What is alicloud's experience of sweeping goods for 100 yuan?
- 【自学unity2d传奇游戏开发】地图编辑器
- 代码重构之法——方法重构分析
- For a while, a dynamic thread pool was created, and the source code was put into GitHub
- How about small and medium-sized enterprises choose shared office?
- 游戏主题音乐对游戏的作用
- CloudQuery V1.2.0 版本发布
猜你喜欢

Share with Lianyun: is IPFs / filecoin worth investing in?

消息队列(MessageQueue)-分析

代码重构之法——方法重构分析

An article takes you to understand CSS3 picture border

Digital city responds to relevant national policies and vigorously develops the construction of digital twin platform

Even liver three all night, jvm77 high frequency interview questions detailed analysis, this?

【转发】查看lua中userdata的方法

What course of artificial intelligence? Will it replace human work?

小游戏云开发入门

ES6 learning notes (3): teach you to use js object-oriented thinking to realize the function of adding, deleting, modifying and checking tab column
随机推荐
2020年第四届中国 BIM (数字建造)经理高峰论坛即将在杭举办
使用 Iceberg on Kubernetes 打造新一代雲原生資料湖
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
PHP application docking justswap special development kit【 JustSwap.PHP ]
事件监听问题
每个大火的“线上狼人杀”平台,都离不开这个新功能
Asp.Net Core learning notes: Introduction
JVM内存分配 -Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m
[efficiency optimization] Nani? Memory overflow again?! It's time to sum up the wave!!
ado.net和asp.net的关系
【学习】接口测试用例编写和测试关注点
Summary of front-end interview questions (C, s, s) that front-end engineers need to understand (2)
git远程库回退指定版本
给字节的学姐讲如何准备“系统设计面试”
An article will take you to understand SVG gradient knowledge
Use modelarts quickly, zero base white can also play AI!
Markdown tricks
What are Devops
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
Description of phpshe SMS plug-in