From 0e5b74e3dd798703cf842257e528c85bc7c00121 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 15 Aug 2018 12:51:21 +0300 Subject: Configurable video looping, option to not to loop silent videos. Updated localization strings. --- src/components/attachment/attachment.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/components/attachment/attachment.js') diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 775207c0..cc19714d 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -13,6 +13,7 @@ const Attachment = { return { nsfwImage, hideNsfwLocal: this.$store.state.config.hideNsfw, + loopVideo: this.$store.state.config.loopVideo, showHidden: false, loading: false, img: this.type === 'image' && document.createElement('img') @@ -59,6 +60,23 @@ const Attachment = { } else { this.showHidden = !this.showHidden } + }, + onVideoDataLoad (e) { + if (typeof e.srcElement.webkitAudioDecodedByteCount !== 'undefined') { + // non-zero if video has audio track + if (e.srcElement.webkitAudioDecodedByteCount > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof e.srcElement.mozHasAudio !== 'undefined') { + // true if video has audio track + if (e.srcElement.mozHasAudio) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof e.srcElement.audioTracks !== 'undefined') { + if (e.srcElement.audioTracks.length > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } } } } -- cgit v1.2.3-70-g09d2