aboutsummaryrefslogtreecommitdiff
path: root/src/components/video_attachment/video_attachment.js
blob: f0ca7e8992d2923232b2553de200250f9daf5335 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

const VideoAttachment = {
  props: ['attachment', 'controls'],
  data () {
    return {
      loopVideo: this.$store.getters.mergedConfig.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.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
        }
      }
    }
  }
}

export default VideoAttachment