
I'm new to PAD, I'm trying to control an html5 video using javascript. The end goal is to save a screenshot of the video at each second. Every other part of the flow is working, but I just can't get the javascript to execute.
I'm starting by opening a new browser (I've tried both Edge & Chrome). Here's an example of the videos I'm using: https://cdn.jwplayer.com/videos/CX8bzdPa.mp4
I'm waiting for the video element to load, then running the following javascript:
function ExecuteScript() {
$('video').removeAttribute("controls");
$('video').pause();
return $('video').duration;
}
This should remove the visible controls, pause the video and then return the duration. I'll then be looping through the number of seconds, scrubbing to the correct part of the video (also using js), and taking a screenshot.
All of the javascript works fine when run in the console directly, but when I try running in PAD, it just has no effect and the result comes out as undefined. I've been able to get alert("Hello World") working, but not much else.
What am I missing?
I'm being an idiot, it looks like the use of jquery is the problem. Works fine with vanilla js
function ExecuteScript() {
var vid = document.getElementsByTagName("video")[0];
vid.removeAttribute("controls");
vid.pause();
return vid.duration;
}