aboutsummaryrefslogtreecommitdiff
path: root/src/components/video_attachment/video_attachment.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2020-10-17 19:24:07 +0300
committerHenry Jameson <me@hjkos.com>2020-10-17 19:24:07 +0300
commit29ff0be92cfd87ba95d1f78323794dfb1223b514 (patch)
tree79836b7fb5b3e325274a833c34fd4c5f6155ba2d /src/components/video_attachment/video_attachment.js
parenta463959a365a5d618a79c96a26f6506e700d6ea3 (diff)
parent3ca729d09880813420a263221cdc68bcca13a1fb (diff)
Merge remote-tracking branch 'origin/develop' into settings-changed
* origin/develop: (48 commits) fix/leftover-emoji-checkboxes-in-settings Apply 1 suggestion(s) to 1 file(s) Translated using Weblate (Spanish) Translated using Weblate (Persian) Translated using Weblate (Persian) Translated using Weblate (Polish) update changelog Stop click propagation when unhiding nsfw Fix Follow Requests title style Translated using Weblate (Persian) Translated using Weblate (Persian) Translated using Weblate (French) Added translation using Weblate (Persian) Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Chinese (Simplified)) Translated using Weblate (Italian) Translated using Weblate (English) Translated using Weblate (English) Translated using Weblate (Basque) Translated using Weblate (Spanish) ...
Diffstat (limited to 'src/components/video_attachment/video_attachment.js')
-rw-r--r--src/components/video_attachment/video_attachment.js47
1 files changed, 34 insertions, 13 deletions
diff --git a/src/components/video_attachment/video_attachment.js b/src/components/video_attachment/video_attachment.js
index f0ca7e89..107b8985 100644
--- a/src/components/video_attachment/video_attachment.js
+++ b/src/components/video_attachment/video_attachment.js
@@ -3,27 +3,48 @@ const VideoAttachment = {
props: ['attachment', 'controls'],
data () {
return {
- loopVideo: this.$store.getters.mergedConfig.loopVideo
+ blocksSuspend: false,
+ // Start from true because removing "loop" property seems buggy in Vue
+ hasAudio: true
+ }
+ },
+ computed: {
+ loopVideo () {
+ if (this.$store.getters.mergedConfig.loopVideoSilentOnly) {
+ return !this.hasAudio
+ }
+ return this.$store.getters.mergedConfig.loopVideo
}
},
methods: {
- onVideoDataLoad (e) {
+ onPlaying (e) {
+ this.setHasAudio(e)
+ if (this.loopVideo) {
+ this.$emit('play', { looping: true })
+ return
+ }
+ this.$emit('play')
+ },
+ onPaused (e) {
+ this.$emit('pause')
+ },
+ setHasAudio (e) {
const target = e.srcElement || e.target
+ // If hasAudio is false, we've already marked this video to not have audio,
+ // a video can't gain audio out of nowhere so don't bother checking again.
+ if (!this.hasAudio) return
if (typeof target.webkitAudioDecodedByteCount !== 'undefined') {
// non-zero if video has audio track
- if (target.webkitAudioDecodedByteCount > 0) {
- this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
- }
- } else if (typeof target.mozHasAudio !== 'undefined') {
+ if (target.webkitAudioDecodedByteCount > 0) return
+ }
+ if (typeof target.mozHasAudio !== 'undefined') {
// true if video has audio track
- if (target.mozHasAudio) {
- this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
- }
- } else if (typeof target.audioTracks !== 'undefined') {
- if (target.audioTracks.length > 0) {
- this.loopVideo = this.loopVideo && !this.$store.getters.mergedConfig.loopVideoSilentOnly
- }
+ if (target.mozHasAudio) return
+ }
+ if (typeof target.audioTracks !== 'undefined') {
+ if (target.audioTracks.length > 0) return
}
+ this.hasAudio = false
}
}
}