1***@qq.com
1***@qq.com
  • 发布:2018-09-07 16:37
  • 更新:2018-09-07 21:36
  • 阅读:4170

在UNIAPP中想通过H5+的直播功能,我下面这么写貌似不能使用,H5+引入该怎么改呢》

分类:uni-app

<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>
2018-09-07 16:37 负责人:无 分享
已邀请:
DCloud_heavensoft

DCloud_heavensoft

Hello H5+里有一个直播的示例,新建移动app,选Hello H5+,看下源码,比对下

  • 1***@qq.com (作者)

    上面就是从H5+实例上搬过来的。。不行。。不过曲线救国了,我直接把H5+里的页面弄到服务器上当远程H5页面,然后在用uniapp的web-view调用回来,就可以正常使用……

    2018-09-08 18:42

  • 喜欢技术的前端

    回复 1***@qq.com: 你好,我也是web-view可是不停地断开,一般是什么原因呢,需要不停地重新刷新页面

    2019-07-02 16:05

该问题目前已经被锁定, 无法添加新回复