2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import FtCard from '../ft-card/ft-card.vue'
|
|
|
|
|
|
|
|
// I haven't decided which video player I want to use
|
|
|
|
// Need to expirement with both of them to see which one will work best.
|
|
|
|
import videojs from 'video.js'
|
2020-02-18 20:59:01 +00:00
|
|
|
import qualitySelector from '@silvermine/videojs-quality-selector'
|
|
|
|
import 'videojs-vtt-thumbnails'
|
|
|
|
import 'videojs-contrib-quality-levels'
|
|
|
|
import 'videojs-http-source-selector'
|
2020-02-16 18:30:00 +00:00
|
|
|
// import mediaelement from 'mediaelement'
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'FtVideoPlayer',
|
|
|
|
components: {
|
|
|
|
'ft-card': FtCard
|
|
|
|
},
|
|
|
|
props: {
|
2020-02-18 20:59:01 +00:00
|
|
|
sourceList: {
|
|
|
|
type: Array,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
dashSrc: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
hlsSrc: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
captionList: {
|
2020-02-16 18:30:00 +00:00
|
|
|
type: Array,
|
|
|
|
default: () => { return [] }
|
|
|
|
},
|
2020-02-18 20:59:01 +00:00
|
|
|
storyboardSrc: {
|
2020-02-16 18:30:00 +00:00
|
|
|
type: String,
|
2020-02-18 20:59:01 +00:00
|
|
|
default: ''
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
id: '',
|
|
|
|
player: null,
|
2020-02-18 20:59:01 +00:00
|
|
|
useDash: false,
|
|
|
|
useHls: false,
|
|
|
|
activeSourceList: [],
|
2020-02-16 18:30:00 +00:00
|
|
|
dataSetup: {
|
|
|
|
aspectRatio: '16:9',
|
2020-02-18 20:59:01 +00:00
|
|
|
nativeTextTracks: false,
|
|
|
|
plugins: {},
|
|
|
|
controlBar: {
|
|
|
|
children: [
|
|
|
|
'playToggle',
|
|
|
|
'volumePanel',
|
|
|
|
'currentTimeDisplay',
|
|
|
|
'timeDivider',
|
|
|
|
'durationDisplay',
|
|
|
|
'progressControl',
|
|
|
|
'liveDisplay',
|
|
|
|
'seekToLive',
|
|
|
|
'remainingTimeDisplay',
|
|
|
|
'customControlSpacer',
|
|
|
|
'playbackRateMenuButton',
|
|
|
|
'chaptersButton',
|
|
|
|
'descriptionsButton',
|
|
|
|
'subsCapsButton',
|
|
|
|
'audioTrackButton',
|
|
|
|
'QualitySelector',
|
|
|
|
'pictureInPictureToggle',
|
|
|
|
'fullscreenToggle'
|
|
|
|
]
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
playbackRates: [
|
|
|
|
0.25,
|
|
|
|
0.5,
|
|
|
|
0.75,
|
|
|
|
1,
|
|
|
|
1.25,
|
|
|
|
1.5,
|
|
|
|
1.75,
|
|
|
|
2,
|
|
|
|
2.25,
|
|
|
|
2.5,
|
|
|
|
2.75,
|
|
|
|
3
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
listType: function () {
|
|
|
|
return this.$store.getters.getListType
|
2020-02-18 20:59:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
videoFormatPreference: function () {
|
|
|
|
return this.$store.getters.getVideoFormatPreference
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
this.id = this._uid
|
2020-02-18 20:59:01 +00:00
|
|
|
|
|
|
|
this.determineFormatType()
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initializePlayer: function () {
|
|
|
|
const videoPlayer = document.getElementById(this.id)
|
|
|
|
if (videoPlayer !== null) {
|
2020-02-18 20:59:01 +00:00
|
|
|
if (!this.useDash && !this.useHls) {
|
|
|
|
qualitySelector(videojs, { showQualitySelectionLabelInControlBar: true })
|
|
|
|
}
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
this.player = videojs(videoPlayer)
|
2020-02-18 20:59:01 +00:00
|
|
|
|
|
|
|
this.player.vttThumbnails({
|
|
|
|
src: this.storyboardSrc
|
|
|
|
})
|
|
|
|
|
|
|
|
if (this.useDash) {
|
|
|
|
this.dataSetup.plugins.httpSourceSelector = {
|
|
|
|
default: 'auto'
|
|
|
|
}
|
|
|
|
|
|
|
|
this.player.httpSourceSelector()
|
|
|
|
}
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
2020-02-18 20:59:01 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
determineFormatType: function () {
|
|
|
|
if (this.hlsSrc === null && this.dashSrc !== null && this.videoFormatPreference === 'dash') {
|
|
|
|
this.enableDashFormat()
|
|
|
|
} else {
|
|
|
|
this.enableLegacyFormat()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
enableDashFormat: function () {
|
|
|
|
if (this.dashSrc === null) {
|
|
|
|
console.log('No dash format available.')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('using dash format')
|
|
|
|
|
|
|
|
this.useDash = true
|
|
|
|
this.useHls = false
|
|
|
|
this.activeSourceList = this.dashSrc
|
|
|
|
|
|
|
|
console.log(this.activeSourceList)
|
|
|
|
|
|
|
|
setTimeout(this.initializePlayer, 1000)
|
|
|
|
},
|
|
|
|
|
|
|
|
enableLegacyFormat: function () {
|
|
|
|
if (this.sourceList.length === 0) {
|
|
|
|
console.log('No sources available')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('using legacy format')
|
|
|
|
|
|
|
|
this.useDash = false
|
|
|
|
this.useHls = false
|
|
|
|
this.activeSourceList = this.sourceList
|
|
|
|
|
|
|
|
setTimeout(this.initializePlayer, 100)
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|