2019-01-15 04:23:13 +11:00
|
|
|
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
|
|
|
|
}
|
|
|
|
},
|
2019-01-17 02:27:23 +11:00
|
|
|
created () {
|
|
|
|
document.addEventListener('keyup', e => {
|
|
|
|
if (e.keyCode === 27 && this.showing) { // escape
|
|
|
|
this.hide()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2019-01-15 04:23:13 +11:00
|
|
|
methods: {
|
|
|
|
hide () {
|
|
|
|
this.$store.dispatch('closeMediaViewer')
|
|
|
|
},
|
|
|
|
onVideoDataLoad (e) {
|
2019-01-17 02:27:23 +11:00
|
|
|
if (!e.srcElement) {
|
|
|
|
return
|
|
|
|
}
|
2019-01-15 04:23:13 +11:00
|
|
|
if (typeof e.srcElement.webkitAudioDecodedByteCount !== 'undefined') {
|
|
|
|
// non-zero if video has audio track
|
|
|
|
if (e.srcElement.webkitAudioDecodedByteCount > 0) {
|
2019-01-17 02:27:23 +11:00
|
|
|
this.loopVideo = this.$store.state.config.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
2019-01-15 04:23:13 +11:00
|
|
|
}
|
|
|
|
} else if (typeof e.srcElement.mozHasAudio !== 'undefined') {
|
|
|
|
// true if video has audio track
|
|
|
|
if (e.srcElement.mozHasAudio) {
|
2019-01-17 02:27:23 +11:00
|
|
|
this.loopVideo = this.$store.state.config.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
2019-01-15 04:23:13 +11:00
|
|
|
}
|
|
|
|
} else if (typeof e.srcElement.audioTracks !== 'undefined') {
|
|
|
|
if (e.srcElement.audioTracks.length > 0) {
|
2019-01-17 02:27:23 +11:00
|
|
|
this.loopVideo = this.$store.state.config.loopVideo && !this.$store.state.config.loopVideoSilentOnly
|
2019-01-15 04:23:13 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MediaModal
|