首页 > 编程语言 >uniapp微信小程序直播

uniapp微信小程序直播

时间:2023-04-26 10:13:09浏览次数:32  
标签:uniapp console log index res plugin live 直播 微信

https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/liveplayer/live-player-plugin.html

https://docs.qq.com/doc/DZHhzV0FiYXRQV01i

不能用<live-player>,因为live-player的src要赋值rtmp格式流视频文件,而<navigator>对应的小程序插件只需要从接口获取房间号和图片即可,但首页无法实现一开始的小窗口播放,只能在点开全屏播放后后退会出现小窗浮层

 

manifest.json:

"mp-weixin" : {
        "appid" : "wx25......",
        "setting" : {
            "urlCheck" : false,
            "es6" : false,
            "postcss" : false,
            "minified" : true
        },
        "plugins": {
            "live-player-plugin": {
                "version": "1.3.5",
                "provider": "wx2b03c6e691cd7370"
            }
        },
        "usingComponents" : true,
        "permission" : {},
        "lazyCodeLoading" : "requiredComponents"
    },

 

pages.json:

{
    "pages": [
        {
            "path": "pages/index/index",
            "name":"index",
            "style": {
                "navigationStyle": "custom",
                "navigationBarTitleText": "首页",
                "app-plus": {
                    "bounce": "vertical",
                    "titleNView": {
                        "autoBackButton":"true"
                    }
                },
                "usingComponents": {
                      "subscribe": "plugin-private://wx2b03c6e691cd7370/components/subscribe/subscribe"
                }
            }
        }
    ],
    "globalStyle": {
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "网",
        "navigationBarBackgroundColor": "#F7F5F6",
        "backgroundColor": "#F7F5F6",
        "app-plus": {
            "titleNView": {  
                "backgroundImage":"#00b4ed"
            }  
        }
    },
    "lazyCodeLoading":"requiredComponents"
}

 

index.vue:

<template>
    <view class="container">
        <view v-show="liveFlag">
        <view class="zhibo">
            <view class="zhibo_right">
                <view class="live" >
                    <navigator :url="live.url" style=" height: 100%;">
                        <view class="liveBtn" >直播中</view>
                        <image class="liveImg" :src="live.curUrl" mode="aspectFill"></image>
                    </navigator>
                </view>
            </view>
        </view>
        </view>
        <view class="bottomV"></view>
        <Tabbar></Tabbar>
    </view>
</template>

<script>// let livePlayer = requirePlugin('live-player-plugin')
    export default {
        name:'index',
        components: {},
        data() {
            return {
                title:'首页',
                liveFlag:false,
                live:{
                    url:'',
                    autoplay:'true',
                    mode:'live',
                    picture:["push", "pop"],
                    roomId:0,
                    customParams:'',
                    curUrl:''
                }
            }
        },
        onl oad() {
            //console.log('1')
            //监听页面加载,参数为上一个页面传递的数据,类型为Object
        },
        onShow(){
            //console.log('2')
            //监听页面的显示,页面每次出现在屏幕上都会触发this.getDate();
        },    
        methods: {
       //无用 activeLive(){ this.live.customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })) // 开发者在直播间页面路径上携带自定义参数(如示例中的path和pid参数),后续可以在分享卡片链接和跳转至商详页时获取,详见【获取自定义参数】、【直播间到商详页面携带参数】章节(上限600个字符,超过部分会被截断) var curUrl = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + this.live.roomId + '&custom_params=' + this.live.customParams wx.navigateTo({ url: curUrl }) }, getDate(){ uni.request({ url: this.$httpUrl.HomeDataGetList, method: 'POST', header:{ 'Content-Type': 'application/x-www-form-urlencoded', }, success: (res) => { // console.log(res) if (res.data.s.co === 1) { let info = res.data.d.rd; //console.log(info) //5直播 info.forEach((item,index)=>{ if(item.Classify == 5){ this.liveFlag = true this.live.roomId = Number(item.Url)  //获取到房间号 this.live.curUrl = item.ImgUrl    //获取到主播上传照片 // this.live.curUrl = 'http://img.myqpw.com/a/5/2/9/4/8/5121359236477258585.jpg'//'https://img.myqpw.com/mini/static/image/head.jpg' this.live.url = 'plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=' + this.live.roomId + '&type=10' // livePlayer.getSubscribeStatus({ room_id: this.live.roomId }).then(res => { // console.log('房间号:', res.room_id) // console.log('订阅用户openid', res.openid) // console.log('是否订阅', res.is_subscribe) // }).catch(err => { // console.log('get subscribe status', err) // }) } }) } else { // uni.showToast({ // title: res.data.s.mg, // icon: "none", // duration: 2000 // }); } } }) } } } </script> <style lang="scss" scoped> .container { .zhibo{ display: flex; .zhibo_right{ width:50%; margin-top:20rpx; .live{ position:relative; height:100%; display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; flex-direction: column; margin-right:20rpx; .liveBtn{ position: absolute; top:10rpx; left:10rpx; z-index: 1; width: 100rpx; height: 40rpx; line-height: 40rpx; border: none; border-radius: 20rpx; font-size: 24rpx; color:#FFFFFF; text-align: center; background: linear-gradient(90deg, rgba(180, 101, 218, 1) 0%, rgba(207, 108, 201, 1) 33%, rgba(238, 96, 156, 1) 66%, rgba(238, 96, 156, 1) 100%) !important; } .liveImg{ width:100%; height:100%; border-radius:15rpx; } } } } } </style>

 

标签:uniapp,console,log,index,res,plugin,live,直播,微信
From: https://www.cnblogs.com/liufeiran/p/17354802.html

相关文章

  • 监控自建MySQL慢查询日志并上报到企业微信集群
    shell脚本如下#!/bin/bash#设置企业微信机器人webhook地址和机器人名称WEBHOOK_URL="你的WEBHOOK_URL"BOT_NAME="MySQLSlowLogBot"#设置慢日志文件路径和记录已发送行数的文件路径LOG_FILE="/data/mysql/mysql-slow-log.log"SENT_LINE_FILE="/tmp/mysql-slow-log.sent......
  • 微信小程序开发
    微信小程序开发者文档:https://developers.weixin.qq.com/miniprogram/dev/component/微信小程序教学视频:https://www.bilibili.com/video/BV1nE41117BQ?p=5&vd_source=77a6f5c488d692a1675c7305a3e29604 1.微信开发者工具介绍: 模拟器底部:可查看页面跳转传递参数添加编译......
  • 爬取虎牙直播的直播间名称以及对应的人数
    首先获得数据定位  按F12打开控制台,点击左上角抓取其中一个直播间的主播名称,观看人数同样操作为了使得到的数据名称与观看人数对应,找到最近的闭合标签,图片中最上面的使闭合标签,第一行是主播名称,第二行是直播间观看人数。标签选择执行“就近原则” 爬取内容结构如下 ......
  • 微信客户端登陆
    界面:<Windowx:Class="WpfApp1.weixin"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.......
  • 您有一份直播回放待查收!
    在各位伙伴们的积极参与下,这次社区版重启直播顺利结束。再次感谢大家对CloudQuery的支持和关注!本文将回顾直播内容、整合用户问题、发布获奖名单,为此次活动画上句点。01直播回顾●社区版的发展历程、重启升级●1.5全新社区版理念●1.5版本新功能展示●社区版后续展望......
  • 微信小程序 swiper scroll 应用
    swiper演示视图wxml<!--中部上游信息--><swiperclass="swiper"autoplaycircularprevious-margin="20rpx"next-margin="60rpx"><swiper-itemwx:for="{{upstreamList}}"wx:key="id"><......
  • 直播商城源码,PopupWindow菜单在ListView中显示
    直播商城源码,PopupWindow菜单在ListView中显示  privatePopupWindowmOperaPopup;  privatevoidshowMenuPopup(Viewanchor)  {    if(mOperaPopup==null)    {      ViewpopupView=View.inflate(mContext,R.layout.popup_opera_sub......
  • 直播软件搭建,为文字/图片添加按压效果
    直播软件搭建,为文字/图片添加按压效果1、文字layout布局: <TextView   android:layout_width="@dimen/textview_button_width"    android:layout_height="match_parent"    android:text="@string/wifi_item_hulv"   android:textColor="@drawa......
  • 直播平台软件开发,一个简单的Android登录实现demo
    直播平台软件开发,一个简单的Android登录实现demo一、登录活动 packagecom.example.login; importandroid.content.Intent;importandroid.os.Bundle;importandroid.text.TextUtils;importandroid.view.View;importandroid.widget.Button;importandroid.widget.EditText......
  • ShareSDK 微信平台注册指南
    注册微信平台账号登录微信开放平台网址微信开放平台网址: https://open.weixin.qq.com/开发者认证1.进入账号中心,进行开发者企业认证2.认证成功后如截图所示注意:开发者企业认证和安卓端需要提交的软著公司需一致,否则需提供软著授权协议证明创建应用填写基本信息按照要求填入填入......