Commit 9cc7c598 by 胡悦

解决安卓手机使用webRTC协议报错的问题

1 parent fa7f579c
......@@ -22,6 +22,7 @@
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<!-- built files will be auto injected -->
<!-- <link href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.1/tcplayer.min.css" rel="stylesheet">
<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.2.1/libs/hls.min.0.13.2m.js"></script>
......
<template>
<div
:class="['live-box',{'videoFullscreen':videoFullscreen}]"
id="live-box"
>
<div class="mask">
<div :class="['live-box', { videoFullscreen: videoFullscreen }]" :style="videoStyle" id="live-box">
<div class="mask" @click="openFullscreen">
<div class="sprite-icon icon-live-close"></div>
<div class="status flex">
<div class="live-line">
......@@ -14,39 +11,21 @@
<div class="text">正在直播</div>
</div>
<template v-if="!IsIOS">
<img
src="https://wimg.588ku.com/gif620/20/04/23/79a7882dfb0c59497976fd8b3bfe60ef.gif"
alt=""
>
<img src="https://wimg.588ku.com/gif620/20/04/23/79a7882dfb0c59497976fd8b3bfe60ef.gif" alt="" />
</template>
</div>
<div
class="fullscreen-btn"
@click="openFullscreen(false)"
>
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png">
<div class="fullscreen-btn" @click="openFullscreen(false)">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png" />
</div>
<div
class="poster-btn"
@click="showKf= true"
>
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif">
<div class="poster-btn" @click="showKf = true">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif" />
</div>
<video
id="player-container-id"
preload="auto"
playsinline
webkit-playsinline
>
</video>
<kf-modal
v-model="showKf"
:detail="detail"
/>
<video id="player-container-id" preload="auto" playsinline webkit-playsinline></video>
<kf-modal v-model="showKf" :detail="detail" />
</div>
</template>
<script type='text/ecmascript-6'>
<script type="text/ecmascript-6">
import { KfModal } from './index'
import { wxConfig } from '@/api'
export default {
......@@ -66,25 +45,32 @@ export default {
mounted () {
let _this = this
wxConfig.ready(() => {
if (Hls.isSupported()) {
_this.video = document.getElementById('player-container-id');
_this.hls = new Hls();
// bind them together
_this.hls.attachMedia(_this.video);
}
_this.player = TCPlayer('player-container-id', {
fileID: '387702305074716718', //点播ID
appID: '1311227058', //点播APPID
autoplay: true, //自动播放
// fileID: '387702305074716718', //点播ID
// appID: '1311227058', //点播APPID
autoplay: true, // 自动播放
loop: true, // 循环播放
muted: true, //是否静音
controlBar: { //控制条配置
fullscreenToggle: false //隐藏全屏按钮
},
webrtcConfig: { //webrtcConfig 参数列表
showLog: true //打印webrtc日志
showLog: true // 打印webrtc日志
}
})
// _this.player.src('http://play.glsx.com.cn/live/live.m3u8') //直播地址
_this.player.src('webrtc://play.glsx.com.cn/live/live_normal')
wx.getNetworkType({
success: (result) => {
_this.player.ready(function () { //设置播放器初始化完成后的回调
console.log('-------------------------', _this.player.poster())
_this.player.play() //播放视频
_this.draggable(document.getElementById('live-box'), _this.openFullscreen)
})
......@@ -93,8 +79,25 @@ export default {
_this.player.on('webrtcevent', function (event) { //监听webrtc
console.log(event)
})
_this.hls.on(Hls.Events.ERROR, function (event, data) {
if (data.fatal) {
switch (data.type) {
case Hls.ErrorTypes.NETWORK_ERROR:
// try to recover network error
console.log('fatal network error encountered, try to recover');
_this.hls.startLoad()
break
case Hls.ErrorTypes.MEDIA_ERROR:
console.log('fatal media error encountered, try to recover');
_this.hls.recoverMediaError();
break;
default:
// cannot recover
_this.hls.destroy();
break;
}
}
});
})
......@@ -113,7 +116,7 @@ export default {
}
</script>
<style scoped lang='scss'>
<style scoped lang="scss">
.live-box {
position: fixed;
top: 23%;
......@@ -123,6 +126,7 @@ export default {
height: 148px;
border-radius: 4px;
overflow: hidden;
-webkit-user-select: auto;
.mask {
width: 100%;
height: 100%;
......@@ -208,4 +212,4 @@ export default {
opacity: 1 !important;
}
}
</style>
\ No newline at end of file
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!