2023-03-17 21:20:51 -04:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<video id="video-player" class="video-js vjs-defaultskin"></video>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
// Importing video-js
|
2023-03-18 13:49:02 -04:00
|
|
|
import videojs from 'video.js'
|
|
|
|
import qualityLevels from 'videojs-contrib-quality-levels'
|
2023-04-06 10:19:59 -04:00
|
|
|
import { createQualitySelector } from '@/assets/qualitySelector'
|
2023-04-10 16:32:58 -04:00
|
|
|
import 'video.js/dist/video-js.css'
|
2023-03-18 13:49:02 -04:00
|
|
|
|
|
|
|
videojs.registerPlugin('qualityLevels', qualityLevels)
|
2023-03-17 21:20:51 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'VideoJsPlayer',
|
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: Object,
|
|
|
|
default() {
|
2023-03-18 13:49:02 -04:00
|
|
|
return {}
|
2023-03-17 21:20:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-07-19 20:26:43 -04:00
|
|
|
emits: ['PlayerTimeUpdate'],
|
2023-03-17 21:20:51 -04:00
|
|
|
data() {
|
|
|
|
let player: any
|
|
|
|
return {
|
|
|
|
player
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// initializing the video player
|
|
|
|
// when the component is being mounted
|
|
|
|
mounted() {
|
2023-07-19 20:26:43 -04:00
|
|
|
const emit = this.$emit
|
2023-04-06 10:19:59 -04:00
|
|
|
this.player = videojs('video-player', this.options, () => {
|
|
|
|
createQualitySelector(this.player)
|
2023-07-19 20:26:43 -04:00
|
|
|
let i = 0
|
|
|
|
|
|
|
|
this.player.on('timeupdate', () => {
|
|
|
|
emit('PlayerTimeUpdate', this.player.currentTime())
|
|
|
|
})
|
2023-04-06 10:19:59 -04:00
|
|
|
})
|
2023-04-10 20:55:53 -04:00
|
|
|
},
|
|
|
|
unmounted() {
|
|
|
|
this.player.dispose()
|
2023-03-17 21:20:51 -04:00
|
|
|
}
|
|
|
|
}
|
2023-03-18 13:49:02 -04:00
|
|
|
</script>
|