Portrait style

更新时间:
复制 MD 格式

This topic describes how to integrate the portrait style component of AUI Kits for interactive live streaming on Android, including procedures, notes, and code examples.

Source code

Download source code

To download the source code, visit the open-source project on GitHub: MediaBox-AUIKits.

Directory structure

├── Android                        // Android platform root directory
│   ├── AUIBaseKits                // AUI base component dependency library
│   ├── AUICore                    // AUI business core dependency library
│   ├── AUIInteractionLiveApp      // AUI interactive live streaming
│   └── AUIUikit                   // AUI business UI component library

Environment requirements

  • Android 5.0 (API level 21) or later.

  • Android Studio 4.0 or later is recommended.

  • A physical device running Android 5.0 or later. Debugging on emulators is not supported.

Prerequisites

  • Set up an AppServer and obtain its domain name. For instructions, see Set up and run the server.

  • Obtain a license and a license key for the push streaming and player features of the ApsaraVideo Client SDK. For more information, see Obtain a license.

Run the demo

Follow these steps to compile and run the demo.

  1. Download and decompress the demo files. To download the files, visit MediaBox-AUIKits.

  2. Configure the project: In Android Studio, choose File > Open and select the downloaded demo project file.

  3. Configure the licenseKey and licensefile. In the <application> tag of the Android/AUIInteractionLiveApp/src/main/AndroidManifest.xml file, enter the licenseKey and licensefile that you obtained from Create an SDK license.

    <!--   TODO: Enter your license information here.     -->
            <!--   Obtain a license: https://help.aliyun.com/document_detail/2391513.html     -->
            <meta-data
                android:name="com.aliyun.alivc_license.licensekey"
                android:value="YOUR_LICENSE_KEY"
                tools:node="replace" />
            <meta-data
                android:name="com.aliyun.alivc_license.licensefile"
                android:value="assets/cert/release.crt"
                tools:node="replace" />
  4. Configure the AppServer address. In the specified code location of the Android/AUICore/AUIAppServer/src/main/java/com/aliyun/auiappserver/RetrofitManager.java file, enter the address of the AppServer that you set up in the Package and run the project section.

    /**
         * TODO: Enter the address of your AppServer.
         */
        public static class Const {
            /**
             * The AppServer address for interactive live streaming (internal IM).
             */
            public static final String APP_SERVER_URL_ALIVC = "";
            /**
             * The AppServer address for interactive live streaming (RongCloud IM).
             */
            public static final String APP_SERVER_URL_RONG_CLOUD = "";
            /**
             * The AppServer address for enterprise live streaming (internal IM).
             */
            public static final String APP_SERVER_URL_ENTERPRISE = "";
        }
  5. Test on a physical device

    1. Connect a physical Android device. Select the device from the device selection drop-down list in the Android Studio toolbar.

    2. Click the green Run button to build the project and deploy it to your physical device.

    3. After the installation is complete, run the interactive live streaming application on your physical device.

Quick integration

Import source code

Obtain the interactive live streaming code repository from the Alibaba Cloud official website or GitHub, and import the base component modules into your project.

Configure license

MediaBox AUI Kits and MediaBox SDKs use the same method to obtain a license. In the console, you can apply for a license to use features such as push streaming, short video, player, and beauty effects. You can also manage the licenses for each module.

Before configuring the license, ensure you have a license and a license key for the push streaming and player features of the ApsaraVideo Client SDK. For more information, see Manage licenses.

  1. In AUIInteractionLiveApp/src/main/AndroidManifest.xml, configure the license key.

    <meta-data
     android:name="com.aliyun.alivc_license.licensekey"
     android:value="YOUR_LICENSE_KEY"
     tools:node="replace" />
  2. Rename the .crt file to release.crt and copy it to the AUIInteractionLiveApp/src/main/assets/cert/ directory.

Initialization

Initialization involves registering the project type and setting the AppServer address. Each project has a Manager class in its App module. To do this, refer to the setup method.

In the AUIInteractionLiveApp project, locate the AUIInteractionLiveManager file. Call its setup method in your application to perform the following operations.

Register project type

private static final String TAG_PROJECT_INTERACTION_LIVE = "aui-live-interaction";
AlivcBase.setIntegrationWay(TAG_PROJECT_INTERACTION_LIVE);

Set AppServer address

Set your AppServer address in RetrofitManager.

RetrofitManager.setAppServerUrl("$YOU NEED TO CHECK THE APP SERVER URL HERE$");

Other project configurations

Note

The following versions are examples. For the latest versions, see README.md.

Maven repository address

maven { url 'https://maven.aliyun.com/nexus/content/repositories/releases' }

Gradle dependencies

implementation "com.aliyun.sdk.android:AliVCInteractionMessage:1.0.0"
implementation 'com.aliyun.aio:AliVCSDK_InteractiveLive:6.7.0'

ProGuard rules

-keep class com.alivc.** { *; }
-keep class com.aliyun.** { *; }
-keep class com.aliyun.rts.network.* { *; }
-keep class org.webrtc.** { *; }
-keep class com.alibaba.dingpaas.** { *; }
-keep class com.dingtalk.mars.** { *; }
-keep class com.dingtalk.bifrost.** { *; }
-keep class com.dingtalk.mobile.** { *; }
-keep class org.android.spdy.** { *; }
-keep class com.alibaba.dingpaas.interaction.** { *; }
-keep class com.cicada.**{*;}

Permissions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<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.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

FAQ

Interactive live streaming use cases

Technical support

For questions or suggestions about AUI Kits, join the AUI Customer Support group on DingTalk by searching for the group ID 35685013712.