diff options
| author | shpuld <shp@cock.li> | 2019-01-26 17:45:03 +0200 |
|---|---|---|
| committer | shpuld <shp@cock.li> | 2019-01-26 17:45:03 +0200 |
| commit | 3978aaef84cc023908155343af76983f2715cf90 (patch) | |
| tree | 0776b181029151d45450e472d1540715040bcab0 /src/components/video_attachment | |
| parent | 8761e039d04ff26944c87339ef55d2951a42696c (diff) | |
Redo everything in the MR
Diffstat (limited to 'src/components/video_attachment')
| -rw-r--r-- | src/components/video_attachment/video_attachment.js | 31 | ||||
| -rw-r--r-- | src/components/video_attachment/video_attachment.vue | 11 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/components/video_attachment/video_attachment.js b/src/components/video_attachment/video_attachment.js new file mode 100644 index 00000000..76b19a02 --- /dev/null +++ b/src/components/video_attachment/video_attachment.js @@ -0,0 +1,31 @@ + +const VideoAttachment = { + props: ['attachment', 'controls'], + data () { + return { + loopVideo: this.$store.state.config.loopVideo + } + }, + methods: { + onVideoDataLoad (e) { + const target = e.srcElement || e.target + if (typeof target.webkitAudioDecodedByteCount !== 'undefined') { + // non-zero if video has audio track + if (target.webkitAudioDecodedByteCount > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof target.mozHasAudio !== 'undefined') { + // true if video has audio track + if (target.mozHasAudio) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof target.audioTracks !== 'undefined') { + if (target.audioTracks.length > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } + } + } +} + +export default VideoAttachment diff --git a/src/components/video_attachment/video_attachment.vue b/src/components/video_attachment/video_attachment.vue new file mode 100644 index 00000000..68de201e --- /dev/null +++ b/src/components/video_attachment/video_attachment.vue @@ -0,0 +1,11 @@ +<template> + <video class="video" + @loadeddata="onVideoDataLoad" + :src="attachment.url" + :loop="loopVideo" + :controls="controls" + playsinline + /> +</template> + +<script src="./video_attachment.js"></script> |
