aboutsummaryrefslogtreecommitdiff
path: root/src/components/attachment/attachment.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2018-08-15 12:51:21 +0300
committerHenry Jameson <me@hjkos.com>2018-08-15 12:51:21 +0300
commit0e5b74e3dd798703cf842257e528c85bc7c00121 (patch)
tree06ecbf3f3befb363543d92c2fda6b880660b0c0a /src/components/attachment/attachment.js
parentd2ec70c3237844333b914c2d26b88f4afc9e0875 (diff)
Configurable video looping, option to not to loop silent videos. Updated
localization strings.
Diffstat (limited to 'src/components/attachment/attachment.js')
-rw-r--r--src/components/attachment/attachment.js18
1 files changed, 18 insertions, 0 deletions
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
+ }
+ }
}
}
}