【发布时间】:2021-06-17 20:13:53
【问题描述】:
我的网站上有一个视频库页面,我需要在此页面上显示上传到 MUX 服务器的视频。我在通过这个库播放视频时遇到问题。文档:https://docs.mux.com/guides/video/playback-videojs-with-mux。 代码示例:
<template>
<div>
<div class="video_conteiner_iframe" v-if="video.status === 'ready' && open">
<iframe
v-if="video.api_type === '1'"
:ref="`video_${video.id}`"
:src="`https://cdn.jwplayer.com/players/${video.key}-hSb3JUAg.html`"
class="video"
frameborder="0"
scrolling="auto"
:title="video.name"
allowfullscreen
/>
<video
v-else
:id="video.id"
class="video-js"
controls
preload="auto"
width="100%"
>
<source :src="video.key" type="video/mux" />
</video>
</div>
<div
v-if="video.status === 'ready' && !open"
class="img_body"
@click="openVideo(video.id, video.key)"
>
<div class="play_video">
<div class="play_block" />
</div>
<img
v-if="video.api_type === '1'"
class="video"
:src="`https://cdn.jwplayer.com/thumbs/${video.key}-640.jpg`"
:alt="`${video.key}`"
>
<img
v-else
class="video"
:src="`https://image.mux.com/${video.key}/thumbnail.png`"
:alt="`${video.key}`"
>
</div>
</div>
</template>
<script>
import videojs from '@mux/videojs-kit';
import '@mux/videojs-kit/dist/index.css';
export default {
name: 'vm-video-play',
props: {
video: { type: Object, required: true }
},
data() {
return {
open: false
};
},
methods: {
openVideo(id, key) {
if (window.innerWidth < 1000 && this.$route.name === 'seller-catalogue-id') {
console.log('modal');
} else {
this.open = true;
}
}
}
};
</script>
video.key === PLAYBACK_ID
如果您尝试播放一些 mp4 视频(例如,https://www.w3schools.com/html/mov_bbb.mp4)而不是 MUX 视频文件,那么它可以正常工作,但不会显示 MUX 视频文件。
【问题讨论】:
-
嘿,我从没用过这个。您能否以某种方式为我们提供一个工作示例?
-
另外,您能否删除问题中与(mux +
video标签)无关的所有内容?他们可能会干扰,我们只想关注这 2 个。另外,你确定最后你会得到这样的东西吗?<source src="d1231asd" />?
标签: vue.js nuxt.js html5-video video.js