(1)、在入口页面 index.html 中引入 SkeyeWebPlayer.js
<html>
<head>
<title>template</title>
<script src="static/libs/SkeyeWebPlayer.js"></script>
</head>
</html>
(2)、在 vue 组件中引入 SkeyeWebPlayer.js
import WebMediaPlayer from '../static/libs/SkeyeWebPlayer/SkeyeWebPlayer'
<template>
<div class="player-group" id="skeyePlayer"></div>
</template>
<script>
export default {data() {
return {player: null}
},
mounted() {this.$nextTick(() => {this.initPlayer()
});
},
beforeDestroy() {if (this.player) {this.player.destroy();
}
},
methods: {initPlayer() {
// new WebMediaPlayer(url,domId,callback,options)this.player = new WebMediaPlayer(
'url',
'skeyePlayer'`,
this.callbackFunc,
{
cbUserPtr: this,
decodeType: 'auto',
openAudio: 0,
BigPlay: false
});
this.player.play('', 1, 0);
},
// 播放器回调办法
callbackFunc(cbType, cbParams) {if (cbType == 'playbackTime') {//console.log("以后回放工夫:" + cbParams);
} else if (cbType == 'ended') {console.log("播放完结");
}
//console.log("Callback" + cbType + ":" + cbParams);
}
}
}
</script>