aboutsummaryrefslogtreecommitdiff
path: root/src/components/video_attachment/video_attachment.js
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2020-10-01 12:54:54 +0000
committerShpuld Shpludson <shp@cock.li>2020-10-01 12:54:54 +0000
commit8a34ff2957e28f7531c62c793ea4f24558e08ced (patch)
treea631749e1fe647085d2ea328b5840b56b344b04e /src/components/video_attachment/video_attachment.js
parentfa9176651952468ee996abe0e67d62d9a72d5a69 (diff)
parent68c2a5b18f887f3db2f5685953bc5175aaaabbd3 (diff)
Merge branch 'develop' into 'feat/masto-ws-deletes'
# Conflicts: # CHANGELOG.md # src/components/status/status.js # src/components/status/status.scss
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
}
}
}