...
|
...
|
@@ -24,12 +24,12 @@ |
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { get } from "lodash";
|
|
|
import videojs from "video.js";
|
|
|
import { getArticleImageSize, processImage } from "utils/image-handler";
|
|
|
import { get } from 'lodash';
|
|
|
import videojs from 'video.js';
|
|
|
import { getArticleImageSize, processImage } from 'utils/image-handler';
|
|
|
|
|
|
export default {
|
|
|
name: "VideoPlayer",
|
|
|
name: 'VideoPlayer',
|
|
|
props: {
|
|
|
source: String,
|
|
|
cover: String,
|
...
|
...
|
@@ -41,7 +41,7 @@ export default { |
|
|
return {
|
|
|
muted: true,
|
|
|
controls: true,
|
|
|
aspectRatio: "1:1"
|
|
|
aspectRatio: '1:1'
|
|
|
};
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -68,45 +68,45 @@ export default { |
|
|
2,
|
|
|
imgSize.width,
|
|
|
imgSize.height,
|
|
|
get(this.yoho, "window.supportWebp")
|
|
|
get(this.yoho, 'window.supportWebp')
|
|
|
);
|
|
|
} else {
|
|
|
return this.cover.split("?")[0];
|
|
|
return this.cover.split('?')[0];
|
|
|
}
|
|
|
} else {
|
|
|
return "";
|
|
|
return '';
|
|
|
}
|
|
|
},
|
|
|
sourceType() {
|
|
|
let type = "video/mp4";
|
|
|
let type = 'video/mp4';
|
|
|
|
|
|
if (this.source) {
|
|
|
let source = this.source.split("?")[0];
|
|
|
let source = this.source.split('?')[0];
|
|
|
|
|
|
source = source.split(".");
|
|
|
source = source.split('.');
|
|
|
|
|
|
switch (source[source.length - 1]) {
|
|
|
case "opus":
|
|
|
case "ogv":
|
|
|
type = "video/ogg";
|
|
|
case 'opus':
|
|
|
case 'ogv':
|
|
|
type = 'video/ogg';
|
|
|
break;
|
|
|
case "mkv":
|
|
|
type = "video/x-matroska";
|
|
|
case 'mkv':
|
|
|
type = 'video/x-matroska';
|
|
|
break;
|
|
|
case "m3u8":
|
|
|
type = "application/x-mpegURL";
|
|
|
case 'm3u8':
|
|
|
type = 'application/x-mpegURL';
|
|
|
break;
|
|
|
case "m4a":
|
|
|
type = "audio/mp4";
|
|
|
case 'm4a':
|
|
|
type = 'audio/mp4';
|
|
|
break;
|
|
|
case "mp3":
|
|
|
type = "audio/mpeg";
|
|
|
case 'mp3':
|
|
|
type = 'audio/mpeg';
|
|
|
break;
|
|
|
case "aac":
|
|
|
type = "audio/aac";
|
|
|
case 'aac':
|
|
|
type = 'audio/aac';
|
|
|
break;
|
|
|
case "oga":
|
|
|
type = "audio/ogg";
|
|
|
case 'oga':
|
|
|
type = 'audio/ogg';
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
...
|
...
|
@@ -131,7 +131,6 @@ export default { |
|
|
},
|
|
|
methods: {
|
|
|
async parentHandleclick() {
|
|
|
// await this.delay(1000);
|
|
|
this.player.play();
|
|
|
|
|
|
const timeId = setTimeout(() => {
|
...
|
...
|
@@ -155,37 +154,37 @@ export default { |
|
|
});
|
|
|
},
|
|
|
initPlayer() {
|
|
|
const noVioceClass = "vjs-yoho-novoice";
|
|
|
const noVioceClass = 'vjs-yoho-novoice';
|
|
|
|
|
|
this.player = videojs(this.$refs.videoPlayer, this.options);
|
|
|
|
|
|
this.voiceBtn = this.player.addChild("button");
|
|
|
this.voiceBtn.addClass("vjs-yoho-voice");
|
|
|
this.voiceBtn = this.player.addChild('button');
|
|
|
this.voiceBtn.addClass('vjs-yoho-voice');
|
|
|
this.voiceBtn.addClass(noVioceClass);
|
|
|
this.backBtn = this.player.addChild("button");
|
|
|
this.backBtn.addClass("vjs-yoho-back");
|
|
|
this.voiceBtn.on("touchend", () => {
|
|
|
this.backBtn = this.player.addChild('button');
|
|
|
this.backBtn.addClass('vjs-yoho-back');
|
|
|
this.voiceBtn.on('touchend', () => {
|
|
|
this.player.muted(!this.voiceBtn.hasClass(noVioceClass));
|
|
|
});
|
|
|
this.backBtn.on("touchend", () => {
|
|
|
this.backBtn.on('touchend', () => {
|
|
|
this.player.exitFullscreen();
|
|
|
});
|
|
|
|
|
|
this.player.on("play", () => {
|
|
|
this.player.on('play', () => {
|
|
|
this.player._yohoPlayTime = this.getTime();
|
|
|
});
|
|
|
this.player.on("pause", () => {
|
|
|
this.player.on('pause', () => {
|
|
|
this.player._yohoPauseTime = this.getTime();
|
|
|
});
|
|
|
this.player.on("ended", () => {
|
|
|
this.player.on('ended', () => {
|
|
|
this.player._yohoEndedTime = this.getTime();
|
|
|
});
|
|
|
|
|
|
this.player.on("fullscreenchange", () => {
|
|
|
this.player.on('fullscreenchange', () => {
|
|
|
this.player._yohoPlayTime = this.getTime();
|
|
|
});
|
|
|
|
|
|
this.player.on("volumechange", () => {
|
|
|
this.player.on('volumechange', () => {
|
|
|
const soundOff = this.player.muted() || this.player.volume() === 0;
|
|
|
|
|
|
if (soundOff) {
|
...
|
...
|
@@ -205,7 +204,7 @@ export default { |
|
|
<style lang="scss" scoped>
|
|
|
.video-js {
|
|
|
width: 100%;
|
|
|
height: auto;
|
|
|
height: 750px;
|
|
|
|
|
|
video {
|
|
|
width: 100%;
|
...
|
...
|
|