yarn add vue-h265-player
# or
npm i vue-h265-player
-
copy decoder to public
cp node_modules/h265-player/lib/libDecoder.wasm public/
-
Introducing components
-
configuration parameter
props:
- url: 需要播放的链接,播放器会根据该值的变化自动重启
- maxRetryCount: 最大尝试重连次数,到达次数上限后会触发
on-error
events:
- on-error: 链接不可用时会触发该方法
<template>
<div id="app">
<H265Player
@on-error="handleOnError"
:url="url"
style="width: 80vw;height:45vw"
/>
</div>
</template>
<script>
import H265Player from 'vue-h265-player';
export default {
name: 'App',
components: {
H265Player,
},
data: () => ({
url: 'a h265 hls url',
}),
methods: {
handleOnError(error) {
console.log('error: ', error);
},
},
};
</script>