diff --git a/src/components/video_attachment/video_attachment.js b/src/components/video_attachment/video_attachment.js index feba25221..107b89855 100644 --- a/src/components/video_attachment/video_attachment.js +++ b/src/components/video_attachment/video_attachment.js @@ -4,7 +4,8 @@ const VideoAttachment = { data () { return { blocksSuspend: false, - hasAudio: false + // Start from true because removing "loop" property seems buggy in Vue + hasAudio: true } }, computed: { @@ -29,26 +30,21 @@ const VideoAttachment = { }, setHasAudio (e) { const target = e.srcElement || e.target - // If hasAudio is true, we've already marked this video to have audio, - // videos can never lose audio so don't bother checking again. - if (this.hasAudio) return + // 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.hasAudio = true - } + if (target.webkitAudioDecodedByteCount > 0) return } if (typeof target.mozHasAudio !== 'undefined') { // true if video has audio track - if (target.mozHasAudio) { - this.hasAudio = true - } + if (target.mozHasAudio) return } if (typeof target.audioTracks !== 'undefined') { - if (target.audioTracks.length > 0) { - this.hasAudio = true - } + if (target.audioTracks.length > 0) return } + this.hasAudio = false } } }