vue-video-player 播放rtmp
时间: 2023-11-25 08:52:22 浏览: 52
以下是使用vue-video-player播放rtmp的示例代码:
```vue
<template>
<div>
<video-player ref="videoPlayer" :options="playerOptions"></video-player>
</div>
</template>
<script>
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
import VideoPlayer from 'vue-video-player'
export default {
components: {
VideoPlayer
},
data() {
return {
playerOptions: {
autoplay: true,
muted: true,
controls: true,
sources: [{
type: 'rtmp/mp4',
src: 'rtmp://your-rtmp-url.com/live/stream'
}]
}
}
},
mounted() {
this.$refs.videoPlayer.play()
}
}
</script>
```
在上述代码中,我们首先导入了vue-video-player和相关的样式文件。然后在组件中使用video-player标签,并将rtmp流的地址作为sources属性传递给playerOptions对象。最后在mounted钩子函数中调用play()方法开始播放视频。