invert hasAudio logic
This commit is contained in:
parent
14e6c0354d
commit
5a447cc2ad
1 changed files with 9 additions and 13 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue