Vue 中使用 flv.js 播放视频
引入依赖
npm install --save flv.js
<template> <div> <video autoplay controls width="100%" height="500" id="videoElement"></video> </div> </template> <script> import flvjs from 'flv.js' export default { name: 'HelloWorld', props: { msg: String }, mounted() { this.$nextTick(() => { this.createVideo() }) }, methods: { createVideo() { if (flvjs.isSupported()) { var videoElement = document.getElementById('videoElement'); var flvPlayer = flvjs.createPlayer({ type: 'flv', url: 'url' //你的url地址 }); flvPlayer.attachMediaElement(videoElement); flvPlayer.load(); flvPlayer.play(); } } } } </script>
本文来自博客园,作者:じ逐梦,转载请注明原文链接:https://www.cnblogs.com/ZhuMeng-Chao/p/18108636