当前位置: 首页 > 工具软件 > Flare Video > 使用案例 >

video播放flv流

程沛
2023-12-01

下载flv.js

npm i flv.js
// vue2
import flvjs from "flv.js";
getVideo (){
if (flvjs.isSupported()) {
            let video = this.$refs.video;
            this.flvPlayer = flvjs.createPlayer({
                type: "flv",
                url: urlss, //直播地址
            });
            this.flvPlayer.attachMediaElement(video);
            this.flvPlayer.load();
            this.flvPlayer.play();
        }
}

// vue3
import flvjs from "flv.js";
import { getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
const getVideo = ()=>{
if (flvjs.isSupported()) {
            let video = proxy.$refs.video;
            proxy.flvPlayer = flvjs.createPlayer({
                type: "flv",
                url: urlss, //直播地址
            });
            proxy.flvPlayer.attachMediaElement(video);
            proxy.flvPlayer.load();
            proxy.flvPlayer.play();
        }
}
<video ref="video" controls autoplay muted loop="loop" preload="auto"
                                style="width: 100%; height: 228px"></video>
 类似资料: