Timeline virtual scrolling
This commit is contained in:
parent
38189ee838
commit
f174f289a9
21 changed files with 204 additions and 39 deletions
|
@ -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') {
|
||||
// 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.webkitAudioDecodedByteCount > 0) return
|
||||
}
|
||||
if (typeof target.mozHasAudio !== 'undefined') {
|
||||
// true if video has audio track
|
||||
if (target.mozHasAudio) return
|
||||
}
|
||||
if (typeof target.audioTracks !== 'undefined') {
|
||||
if (target.audioTracks.length > 0) return
|
||||
}
|
||||
this.hasAudio = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
:alt="attachment.description"
|
||||
:title="attachment.description"
|
||||
playsinline
|
||||
@loadeddata="onVideoDataLoad"
|
||||
@playing="onPlaying"
|
||||
@pause="onPaused"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue