/* play video twice as fast */
document.querySelector('video').defaultPlaybackRate = 2.0;
document.querySelector('video').play();
/* now play three times as fast just for the heck of it */
document.querySelector('video').playbackRate = 3.0;
According to this site, this is supported in the playbackRate and defaultPlaybackRate attributes, accessible via the DOM. Example:
/* play video twice as fast */
document.querySelector('video').defaultPlaybackRate = 2.0;
document.querySelector('video').play();
/* now play three times as fast just for the heck of it */
document.querySelector('video').playbackRate = 3.0;
The above works on Chrome 43+, Firefox 20+, IE 9+, Edge 12+.
(Tested in Chrome while playing videos on YouTube, but should work anywhere--especially useful for speeding up online training videos).
For anyone wanting to add these as "bookmarklets" (bookmarks containing JavaScript code instead of URLs) to your browser, use these browser bookmark names and URLs, and add each of the following bookmarks to the top of your browser. When copying the "URL" portion of each bookmark below, copy the entire multi-line code block, new-lines and all, into the "URL" field of your bookmark creation tool in your browser.
var vid = document.getElementById("video1");
function slowPlaySpeed() {
vid.playbackRate = 0.5;
}
function normalPlaySpeed() {
vid.playbackRate = 1;
}
function fastPlaySpeed() {
vid.playbackRate = 2;
}
You can use this code:
var vid = document.getElementById("video1");
function slowPlaySpeed() {
vid.playbackRate = 0.5;
}
function normalPlaySpeed() {
vid.playbackRate = 1;
}
function fastPlaySpeed() {
vid.playbackRate = 2;
}
caught TypeError: Cannot set properties of null (setting 'playbackRate')
due to the first function returning null (meaning it couldn't find the element specified), then the simple solution is to use a typical selector (ID, Class, etc.). But what I've found is that when this error is thrown even though it should not throw an error as there's a video element and it's the only one on the page, the issue is related to the HTML property of tabindex being set to "-1". Simply using browser inspect to get to the video, then removing the "tabindex" property can fix an error as displayed above.
suppose that your video/audio id is myVideo, then you can simply use JavaScript for doing that you wanna do, By just typing the following simple JS code:-
var vid = document.getElementById("myVideo");
vid.playbackRate = 0.5;`
That will decrease the speed of your video/audio to it's half speed.
playbackspeed
Indicates the current playback speed of the audio/video.
发布评论
评论(17)
根据此网站,这在
playbackRate
和defaultPlaybackRate
属性中得到支持,可通过 DOM 访问。示例:上述适用于 Chrome 43+、Firefox 20+、IE 9+、Edge 12+。
According to this site, this is supported in the
playbackRate
anddefaultPlaybackRate
attributes, accessible via the DOM. Example:The above works on Chrome 43+, Firefox 20+, IE 9+, Edge 12+.
输入即可。
只需在现代浏览器的 JS 控制台中
Just type
in JS console of your modern browser.
(在 YouTube 上播放视频时在 Chrome 中进行了测试,但应该可以在任何地方工作 - 对于加快在线培训视频的速度特别有用)。
对于想要将这些作为“小书签”(包含 JavaScript 代码而不是 URL 的书签)添加到浏览器的人,请使用这些浏览器书签名称和 URL,并将以下每个书签添加到您的浏览器顶部浏览器。 复制下面每个书签的“URL”部分时,请将整个多行代码块、换行符和所有内容复制到浏览器中书签创建工具的“URL”字段中。
< a href="https://i.sstatic.net/WU46Y.png" rel="noreferrer">
名称: 0.5x
网址:
名称: 1.0x
网址:
名称: 1.5x
网址:
名称: 2.0x
URL:
以下是我所有的播放速度书签:
我将上述所有播放速度书签以及更多内容添加到书签栏上名为
1.00x
的文件夹中,如下所示:参考文献:
(Tested in Chrome while playing videos on YouTube, but should work anywhere--especially useful for speeding up online training videos).
For anyone wanting to add these as "bookmarklets" (bookmarks containing JavaScript code instead of URLs) to your browser, use these browser bookmark names and URLs, and add each of the following bookmarks to the top of your browser. When copying the "URL" portion of each bookmark below, copy the entire multi-line code block, new-lines and all, into the "URL" field of your bookmark creation tool in your browser.
Name: 0.5x
URL:
Name: 1.0x
URL:
Name: 1.5x
URL:
Name: 2.0x
URL:
Here are all of my playback-speed bookmarklets:
I added all of the above playback speed bookmarklets, and more, into a folder named
1.00x
on my bookmark bar, as shown here:References:
解决
onloadstart="this.playbackRate = 1.5;"
video.playbackRate = 1.5;
演示
https://codepen.io/xgqfrms/pen/dydwzjp
solutions
onloadstart="this.playbackRate = 1.5;"
video.playbackRate = 1.5;
demo
https://codepen.io/xgqfrms/pen/dydwzjp
我更喜欢对视频速度进行更精细的调整。我喜欢能够根据命令加快和减慢视频速度。因此我使用这个:
按 d 加速,按 s 减速。
I prefer having a more fine tuned approach for video speed. I like being able to speed up and slow down the video on command. Thus I use this:
Press d to speed up, s to slow down.
您可以使用此代码:
You can use this code:
在 Chrome 中,创建一个新书签
输入任意名称,例如速度选择器,然后在 URL javascript 中输入以下代码
:
然后当您单击此书签时,会出现一个弹出窗口,然后您可以输入视频的速度
In chrome, create a new bookmark
Enter an arbitarary name for example speed selector then Enter the following code in the URL
javascript:
then when you click on this bookmark, a popup window appears then you can enter the speed of video
您可以在此处输入任何数字,但不要输入太多,以免计算机过载。
you can put any number here just don't go to far so you don't overun your computer.
它总是有效你可以尝试这个
It works always you can try this
如上所述,一般的解决方案是:
但是,如果这返回一个错误,例如:
由于第一个函数返回 null(意味着它找不到指定的元素),那么简单的解决方案是使用典型的选择器( ID、类别等)。但我发现,当抛出此错误时,即使它不应该抛出错误,因为有一个视频元素并且它是页面上唯一的一个,问题与 tabindex 的 HTML 属性设置为“- 1”。只需使用浏览器检查来访问视频,然后删除“tabindex”属性即可修复如上所示的错误。
As posted above, the general solution to this is:
However, if this returns an error like:
due to the first function returning null (meaning it couldn't find the element specified), then the simple solution is to use a typical selector (ID, Class, etc.). But what I've found is that when this error is thrown even though it should not throw an error as there's a video element and it's the only one on the page, the issue is related to the HTML property of tabindex being set to "-1". Simply using browser inspect to get to the video, then removing the "tabindex" property can fix an error as displayed above.
假设您的视频/音频 id 是
myVideo
,那么您可以简单地使用 JavaScript 来完成您想做的事情,只需键入以下简单的 JS 代码: -playbackspeedThat will decrease the speed of your video/audio to it's half speed.
指示
音频/的当前播放速度视频。
示例值:
1.0 是正常速度
0.5 是半速(较慢)
2.0 是双倍速度(较快)
-1.0 是向后,正常速度
-0.5 是向后,半速
来源: w3schools.com
suppose that your video/audio id is
myVideo
, then you can simply use JavaScript for doing that you wanna do, By just typing the following simple JS code:-That will decrease the speed of your video/audio to it's half speed.
playbackspeed
Indicates the current playback speed of the audio/video.
Example values:
1.0 is normal speed
0.5 is half speed (slower)
2.0 is double speed (faster)
-1.0 is backwards, normal speed
-0.5 is backwards, half speed
source: w3schools.com
只需在浏览器的 JavaScript 控制台中键入以下命令:
您可以通过从右键菜单中选择检查选项来获取它,如下所示:
Just type the following command in the javascript console of your browser:
You can get it by choosing the inspect option from the right-click menu as follows:
右键单击
。
Firefox has a speed control context menu when you right-click
.
如果页面上有多个视频,则大多数其他答案只会更改第一个视频。
javascript:document.querySelectorAll('video').forEach( (vid) => vid.playbackRate = 1.5 );
^^ 此书签将加快打开页面上所有视频的速度。
If there are multiple videos on the page, most of other answers will only change the first one.
javascript:document.querySelectorAll('video').forEach( (vid) => vid.playbackRate = 1.5 );
^^ this bookmarklet will speed up all videos on the open page.
使用反应:
using React:
<视频
src={USERBG}
自动播放
环形
静音
控制
onLoadStart={(e) =>; (e.target.playbackRate = 0.5)}
className="object-cover object-center w-full h-full 固定 top-0 left-0 z-10"
>
<video
src={USERBG}
autoPlay
loop
muted
controls
onLoadStart={(e) => (e.target.playbackRate = 0.5)}
className="object-cover object-center w-full h-full fixed top-0 left-0 z-10"
>
document.querySelector('video').playbackRate = 16.0;
在 Chrome 2024 中最大速度 16
document.querySelector('video').playbackRate = 16.0;
In Chrome 2024 max speed 16