diff options
author | Jeremy White <jwhite@codeweavers.com> | 2019-12-31 10:50:32 -0600 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2020-04-09 09:13:16 +0100 |
commit | e2dec1cea47c62e65d0141974b1f453024eac7a2 (patch) | |
tree | 904f3300b4e452adef50b4540b546c034bfca209 | |
parent | 2c36a2474b96dc781040d29de726c5b60b318b56 (diff) |
Make an attempt to follow the rules on auto play videos.
Browsers have stopped allowing auto play videos. The documented solution
is to mute your video. This patch mutes our videos and also attempts to
start playing if the auto play does not fire.
Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r-- | src/display.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/display.js b/src/display.js index 4941884..f20d6b4 100644 --- a/src/display.js +++ b/src/display.js @@ -559,6 +559,7 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg) var v = document.createElement("video"); v.src = window.URL.createObjectURL(media); + v.setAttribute('muted', true); v.setAttribute('autoplay', true); v.setAttribute('width', m.stream_width); v.setAttribute('height', m.stream_height); @@ -1146,6 +1147,10 @@ function handle_append_video_buffer_done(e) stream.video.currentTime = stream.video.buffered.start(stream.video.buffered.length - 1); } + /* Modern browsers try not to auto play video. */ + if (this.stream.video.paused && this.stream.video.readyState >= 2) + var promise = this.stream.video.play(); + if (Utils.STREAM_DEBUG > 1) console.log(stream.video.currentTime + ":id " + stream.id + " updateend " + Utils.dump_media_element(stream.video)); } |