I learned a lot from this script and thank you for that. I would suggest a slight modification to function set_zoom so it can handle wide screens - the videos would be zoomed by cropping top and bottom parts of the videos. Something like this:
function set_zoom(video, cw, ch) {
var vs = video.style;
var video_aspect = video.videoWidth/video.videoHeight;
var containing_aspect = cw/ch;
// Don't zoom if the endscreen is showing
if(!video.ended) {
var vh = 0, vw = 0, vt = 0, vl = 0;
if(video_aspect < containing_aspect) {
vw = cw;
vh = vw / video_aspect;
} else {
vh = ch;
vw = video_aspect * vh;
}
vt = (ch-vh)/2;
vl = (cw-vw)/2;
vs.height = vh + "px";
vs.width = vw + "px";
vs.top = vt + "px";
vs.left = vl + "px";
} else {
debug_log("Video has ended. Not setting zoom. (Otherwise we mess with the endscreen.)");
}
}
Of course it's stripped from functionality I didn't need but the idea is preserved.
I learned a lot from this script and thank you for that. I would suggest a slight modification to function set_zoom so it can handle wide screens - the videos would be zoomed by cropping top and bottom parts of the videos. Something like this:
Of course it's stripped from functionality I didn't need but the idea is preserved.