summaryrefslogtreecommitdiff
path: root/localwebsite/templates-web
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-05-23 17:51:03 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-05-23 18:42:13 +0300
commit9a59215f9e7fca3ef940133824afc4aed04815f9 (patch)
tree7c276070de23440484781873a1c861efdc2ce609 /localwebsite/templates-web
parent503d6350921f161b258f41cea4d0ebd0b5e795fc (diff)
localwebsite: cams: debug video events, support iOS
Diffstat (limited to 'localwebsite/templates-web')
-rw-r--r--localwebsite/templates-web/cams.twig28
1 files changed, 25 insertions, 3 deletions
diff --git a/localwebsite/templates-web/cams.twig b/localwebsite/templates-web/cams.twig
index 5d25a9d..cf6009c 100644
--- a/localwebsite/templates-web/cams.twig
+++ b/localwebsite/templates-web/cams.twig
@@ -30,10 +30,32 @@ function setupHls(video, name, useHls) {
video.play();
});
} else {
+ console.warn('hls.js is not supported, trying the native way...')
+
+ video.autoplay = true;
+ video.muted = true;
+ if (window.browserInfo.ios)
+ video.setAttribute('controls', 'controls');
+
video.src = src;
- video.addEventListener('canplay', function () {
- video.play();
- });
+
+ var events = ['canplay'];
+ {% if video_events %}
+ events.push('canplay', 'canplaythrough', 'durationchange', 'ended', 'loadeddata', 'loadedmetadata', 'pause', 'play', 'playing', 'progress', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'waiting');
+ {% endif %}
+
+ for (var i = 0; i < events.length; i++) {
+ var evt = events[i];
+ (function(evt, video, name) {
+ video.addEventListener(evt, function(e) {
+ {% if video_events %}
+ console.log(name + ': ' + evt, e);
+ {% endif %}
+ if (!window.browserInfo.ios && ['canplay', 'loadedmetadata'].includes(evt))
+ video.play();
+ })
+ })(evt, video, name);
+ }
}
}