在data中
vodPlayerJs: "https://player.polyv.net/script/player.js",
this.loadPlayerScript(this.loadPlayer);
if (this.player) {
this.onPause();//两个监听事件
this.onPlay();
}
我这里不知道到底是vid还是URL,所以两个的取值根据传送的参数决定的
loadPlayerScript(callback) {
if (!window.polyvPlayer) {
const myScript = document.createElement("script");
myScript.setAttribute("src", this.vodPlayerJs);
myScript.onload = callback;
document.body.appendChild(myScript);
} else {
callback();
}
},
// 暂停事件
onPause() {
let that=this;
this.player.on("s2j_onVideoPause", function (e) {
that.flag=true;
});
},
// 播放事件
onPlay() {
const _that = this;
this.player.on("s2j_onVideoPlay", function (e) {
_that.flag=false;
});
},
loadPlayer() {
const polyvPlayer = window.polyvPlayer;
this.player = polyvPlayer({
wrap: "#player" + this.index,
width: "100%",
height: "544",
vid: this.vid,
autoplay: false,
ban_preview_video: "on",
allowFullscreen:false,
url: this.url

本文介绍了在Vue项目中如何使用保利威视频播放器,详细讲解了如何处理vid和URL的判断,以及全屏功能的实现。同时分享了自定义菜单栏的方法,包括进度条和音量控制的实现细节。进度条和音量控制的值可以通过保利威官方API获取。文章末尾鼓励有兴趣的读者进行讨论。
最低0.47元/天 解锁文章
5382





