Forum Discussion
SaadSiddiqui-4f
5 years agoCommunity Member
Using JavaScript to change the playback rate of Audio and Video
I'm using the following code to provide variable playback speed in the course.
var player = GetPlayer();
var x = document.getElementsByTagName('video')[0];
x.playbackRate = 2.0;
The code...
MathNotermans-9
5 years agoCommunity Member
Probably that is scope related. If you add a trigger on a slide...its related to that slide and only will work on that slide...
Your code will only work for 1 video. Because of the [0] behind it. That will get the first video on the slide.
If you code it like this...var allVideos = document.getElementsByTagName("video");
it will get all videos.
However then you have to loop the collection of elements you found like this...for (var i = 0; i < allVideos.length; i++) {
allVideos[i].playbackRate = 2.0;
}
Kind regards,
Math
Related Content
- 6 months ago