<template>
<view>
<view class="page-section">
<view id="pusher" class="pu" style="width:100%;height:600px;background-color:#000000;margin:auto"></view>
</view>
<view class="page-section" style="margin-top: 70px;">
<view class="uni-flex uni-row">
<view class="text" style="flex: 1;">
<button class="" type="default" @tap="startPusher()">
开始</button>
</view>
<view class="text" style="flex: 1;">
<button class="" type="default" @tap="pausePusher()">
暂停</button>
</view>
<view class="text" style="flex: 1;">
<button class="" type="default" @tap="resumePusher()">
恢复</button>
</view>
<view class="text" style="flex: 1;">
<button class="" type="default" @tap="closePusher()">
关闭</button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
onLoad: function (option) {
var pusher = null;
// 创建直播推流控件
pusher = new plus.video.LivePusher('pusher', {
url: 'rtmp://31287.livepush.myqcloud.com/live/31287_5845bbfbb27411e892905cb9018cf0d4?bizid=31287'
});
// 监听状态变化事件
pusher.addEventListener('statechange', function (e) {
console.log('statechange: ' + JSON.stringify(e));
}, false);
},
data: {
pusher:''
},
methods: {
startPusher() {
this.pusher.start();
},
// 暂停推流
pausePusher() {
this.pusher.pause();
},
// 恢复推流
resumePusher() {
this.pusher.resume();
},
closePusher() {
this.pusher.close();
}
}
}
</script>
<style>
@import "../../common/uni.css";
@import "../../common/icon.css";
@import "../../common/iconfont.css";
.flex-item {
width: 200px;
height: 300px;
text-align: center;
line-height: 300px;
font-size: 26px;
}
.flex-item-V {
margin: 0 auto;
width: 300px;
height: 200px;
text-align: center;
line-height: 200px;
}
</style>
1***@qq.com
- 发布:2018-09-07 16:37
- 更新:2018-09-07 21:36
- 阅读:4269
1***@qq.com (作者)
上面就是从H5+实例上搬过来的。。不行。。不过曲线救国了,我直接把H5+里的页面弄到服务器上当远程H5页面,然后在用uniapp的web-view调用回来,就可以正常使用……
2018-09-08 18:42
喜欢技术的前端
回复 1***@qq.com: 你好,我也是web-view可是不停地断开,一般是什么原因呢,需要不停地重新刷新页面
2019-07-02 16:05