From 17735943d5cdde1eb852d36f1c3bb699d23f7eb6 Mon Sep 17 00:00:00 2001 From: shpuld Date: Mon, 14 Jan 2019 19:23:13 +0200 Subject: Add media viewer module and media module component, modify attachment behavior --- src/components/media_modal/media_modal.js | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/components/media_modal/media_modal.js (limited to 'src/components/media_modal/media_modal.js') diff --git a/src/components/media_modal/media_modal.js b/src/components/media_modal/media_modal.js new file mode 100644 index 00000000..91601515 --- /dev/null +++ b/src/components/media_modal/media_modal.js @@ -0,0 +1,51 @@ +import StillImage from '../still-image/still-image.vue' +import fileTypeService from '../../services/file_type/file_type.service.js' + +const MediaModal = { + data () { + return { + loopVideo: this.$store.state.config.loopVideo + } + }, + components: { + StillImage + }, + computed: { + showing () { + return this.$store.state.mediaViewer.activated + }, + currentIndex () { + return this.$store.state.mediaViewer.currentIndex + }, + currentMedia () { + return this.$store.state.mediaViewer.media[this.currentIndex] + }, + type () { + return this.currentMedia ? fileTypeService.fileType(this.currentMedia.mimetype) : null + } + }, + methods: { + hide () { + this.$store.dispatch('closeMediaViewer') + }, + onVideoDataLoad (e) { + if (typeof e.srcElement.webkitAudioDecodedByteCount !== 'undefined') { + // non-zero if video has audio track + if (e.srcElement.webkitAudioDecodedByteCount > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof e.srcElement.mozHasAudio !== 'undefined') { + // true if video has audio track + if (e.srcElement.mozHasAudio) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } else if (typeof e.srcElement.audioTracks !== 'undefined') { + if (e.srcElement.audioTracks.length > 0) { + this.loopVideo = this.loopVideo && !this.$store.state.config.loopVideoSilentOnly + } + } + } + } +} + +export default MediaModal -- cgit v1.2.3-70-g09d2