更新记录

1.0.3(2025-04-16)

修复bug

1.0.2(2025-04-15)

修复bug

1.0.1(2025-04-13)

优化细节

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 4.26,Android:不确定,iOS:支持,HarmonyNext:不确定 × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序 鸿蒙元服务
× × × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

yzc-livepusher

rtmp直播推流(已支持iOS。安卓待测试)

需要打自定义基座,uniapp 需要使用nvue,请试用合适后再购买

uniappx用法

参数

参数 类型 是否必须 描述
rtmpurl string 推流地址
mute boolean 静音
beautyFace boolean 美颜|
videoQuality string 分辨率("540p" "720p" "1080p")

方法

|方法名|参数|说明| |startLive|无参|开始直播| |stopLive|无参|停止直播| |swithCamera|无参|切换摄像头|

组件引入

复制代码<live-pusher
class="livePuser"
ref="livePuser"
:rtmpurl="rtmpurl"
:mute="mute"
:beautyFace="beautyFace"
videoQuality="720p"
@liveStateChanged="liveStateChanged"
@premissionFail="premissionFail"
>
</live-pusher>

类型导入

复制代码import { LiveStateType, PerissionFailType } from '@/uni_modules/yzc-livepusher';

选项时API

复制代码export default {
    data() {
        return {
            pushing: false,
            livePusherElement: null as LivePusherElement | null
        }
    },
    methods: {
        pusherBtnClick() {
            if (this.livePusherElement == null) {
                this.livePusherElement = this.$refs['livePuser'] as LivePusherElement
            }
            this.pushing = !this.pushing
            if (this.pushing) {
                this.livePusherElement?.startLive()
            } else {
                this.livePusherElement?.stopLive()
            }
        },
        swithCamera() {
            if (this.livePusherElement == null) {
                this.livePusherElement = this.$refs['livePuser'] as LivePusherElement
            }
            this.livePusherElement?.swithCamera()
        },
        liveStateChanged(state: LiveStateType) {
            console.log('liveStateChanged', state.state)
        },
        premissionFail(type: PerissionFailType) {
            console.log('premissionFail', type.fail)
        }
    }
}

组合式API

复制代码const livePuser = ref(null)
const pushing = ref(false)
const pusherBtnClick = (() => {
    pushing.value = !pushing.value
    if (pushing.value) {
        (livePuser.value as LivePusherElement).startLive()
    } else {
        (livePuser.value as LivePusherElement).stopLive()
    }
})
const swithCamera = (() => {
    (livePuser.value as LivePusherElement).swithCamera()
})
const liveStateChanged = ((state: LiveStateType) => {
    console.log('liveStateChanged', state.state)
})
const premissionFail = ((type: PerissionFailType) => {
    console.log('premissionFail', type.fail)
})

uniapp用法

复制代码export default {
    data() {
        return {
            pushing: false
        }
    },
    methods: {
         pusherBtnClick() {
            this.pushing = !this.pushing
            if (this.pushing) {
                this.$refs['livePuser'].startLive()
            } else {
                this.$refs['livePuser'].stopLive()
            }
         },
         swithCamera() {
            this.$refs['livePuser'].swithCamera()
         },
         liveStateChanged(state) {
            console.log('liveStateChanged', state.detail.state)
         },
         premissionFail(type) {
            console.log('premissionFail', type.detail.fail)
         }
    }
}

liveStateChanged方法回调说明

state说明

类型 描述
'Unknow' 未知
'Connecting' 连接中
'Connected' 已连接
'Disconnected' 断开连接
'Error' 连接错误

premissionFail方法回调说明

type说明 返回为ms的整数类型

类型 描述
'VideoPerissionFail' 相机权限未打开
'AudioPerissionFail' 麦克风权限未打开

隐私、权限声明

1. 本插件需要申请的系统权限列表:

-录像权限 -录音权限

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问