更新记录

1.0.0(2024-06-24)

首次提交


平台兼容性

HbuilderX/cli最低兼容版本
4.15

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios
? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

netease-push-stream

开发文档

UTS 语法 UTS API插件 UTS 组件插件 Hello UTS

Android demo code
vue
<template>
    <scroll-view style="flex: 1">
        <nrtc-push-view id="video" ref="video" class="video" :appkey="appkey">
        </nrtc-push-view>
        <view>
            <view class="input-wrapper">
              <textarea id="uni-input-default" class="uni-input" name="url" :value="url"  type="text" placeholder="请设置推流URL" @input="urlChange" />
            </view>
            <view class="input-wrapper">
                <textarea id="uni-input-default" class="uni-cname-input" name="cname" :value="cname" type="text" placeholder="cname" @input="cnameChange" />
            </view>
            <view class="input-wrapper">
                <textarea id="uni-input-default" class="uni-uid-input" name="uid" :value="uid"  type="text" placeholder="UID" @input="uidChange" />
            </view>
        </view>
        <button class="button" @click="startPush" type="primary">开始推流</button>
        <button class="button" @click="changeAudioVideoConfig" type="primary">音视频参数设置</button>
        <button class="button" @click="stopPush" type="primary">停止推流</button>
    </scroll-view>
</template>

<style scoped>
  .text {
      font-size: 15px;
      color: #353535;
      line-height: 27px;
      text-align: center;
    }

  .input-wrapper {
    display: flex;
    padding: 8px 13px;
    margin: 5px 0;
    flex-direction: row;
    flex-wrap: nowrap;
    background-color: #ffffff;
  }

  .uni-input {
    height: 75px;
    font-size: 15px;
    padding: 0px;
    flex: 1;
    background-color: #ffffff;
  }

  .uni-uid-input {
    height: 21px;
    font-size: 15px;
    padding: 0px;
    flex: 1;
    background-color: #ffffff;
  }

  .uni-cname-input {
    height: 21px;
    font-size: 15px;
    padding: 0px;
    flex: 1;
    background-color: #ffffff;
  }

  .uni-icon {
    width: 24px;
    height: 24px;
  }

  .uni-input-placeholder-class {
    font-size: 10px;
  }
</style>

<script>

    <!-- #ifdef APP-ANDROID -->
        import { NrtcPushViewElement } from "uts.sdk.modules.neteasePushStream"
    <!-- #endif -->

    export default {
        data() {
            return {
                appkey: "", // Add data property for App Key
                url: "", 
                token: "",
                cname: "",
                uid: "",
            };
        },
        onLoad() {

        },

        onShow() {
            (uni.getElementById('video') as NrtcPushViewElement).appOnShow();
        },

        onHide() {
            (uni.getElementById('video') as NrtcPushViewElement).appOnHide();
        },

        methods: {
            urlChange: function(event: UniInputEvent) {
                this.url = event.detail.value
            },

            uidChange: function(event: UniInputEvent) {
                this.uid = event.detail.value
            },

            cnameChange: function(event: UniInputEvent) {
                this.cname = event.detail.value
            },

            startPush() {
                (uni.getElementById('video') as NrtcPushViewElement).startPush(this.token, this.cname, this.uid, this.url);
            },

            stopPush() {
                (uni.getElementById('video') as NrtcPushViewElement).stopPush();
            },

            changeAudioVideoConfig() {
                (uni.getElementById('video') as NrtcPushViewElement).enableLocalVideo(true);
                (uni.getElementById('video') as NrtcPushViewElement).enableLocalAudio(true);

                /*
                DEFAULT = 0
                STANDARD = 1
                STANDARD_EXTEND = 2
                MIDDLE_QUALITY = 3
                MIDDLE_QUALITY_STEREO = 4
                HIGH_QUALITY = 5
                HIGH_QUALITY_STEREO = 6
                */
                (uni.getElementById('video') as NrtcPushViewElement).setAudioProfile(5);

                /*
                参数1
                VideoProfile
                int     Lowest = 0
                int     LOW = 1
                int     STANDARD = 2
                int     HD720P = 3
                int     HD1080p = 4
                参数2
                VideoCropMode
                NERtcConstants.VideoCropMode::DEFAULT
                NERtcConstants.VideoCropMode::CROP_16x9
                NERtcConstants.VideoCropMode::CROP_4x3
                NERtcConstants.VideoCropMode::CROP_1x1
                */
                (uni.getElementById('video') as NrtcPushViewElement).setLocalVideoConfig(3, 3);
            }
        }
    }
</script>

<style>
    .content {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .logo {
        height: 200rpx;
        width: 200rpx;
        margin-top: 200rpx;
        margin-bottom: 50rpx;
    }

    .title {
        font-size: 36rpx;
        color: #8f8f94;
    }

    .video {
        width: 750rpx;
        height: 750rpx;
    }

    .button {
        width: 710rpx;
        margin: 10px;
    }
</style>

隐私、权限声明

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

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 外置存储存取权限 --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 多媒体相关 --> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <!-- 8.0+系统需要--> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

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

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

许可协议

MIT协议

暂无用户评论。

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