Getting Started

更新时间:
复制 MD 格式

Audio and video calls are supported only in baseline 10.1.68 and later.

Prerequisites

  • If you use the native AAR approach, first complete Add mPaaS to your project. Then, make sure that the build.gradle file in the project's root directory contains the following dependency:

    classpath 'com.android.boost.easyconfig:easyconfig:2.8.4'

    Make sure that the build.gradle file of the main project (android main module) contains the following configuration:

    apply plugin: 'com.alipay.apollo.baseline.config'
  • If you use the component-based (Portal & Bundle) approach, first complete the component-based integration process.

Add the SDK

Native AAR approach

Follow the instructions in AAR component management to install the Audio and Video Call component in your project using Component Management (AAR).

Component-based approach

In your Portal and Bundle projects, install the Audio and Video Call component using Component Management. For more information, see Manage component dependencies.

Initialize mPaaS

If you use the native AAR approach, you need to initialize mPaaS.

Add the following code to your Application class:

public class MyApplication extends Application {
    
    @Override
    public void onCreate() {
        super.onCreate();
        // Initialize mPaaS
        MP.init(this);    
    }
}

For more information, see Initialize mPaaS.

Use the SDK

  1. Initialize the engine and enable automatic publishing and subscribing by setting autoPublish and autoSubscribe to true.

    AlipayRtcEngine rtcEngine = AlipayRtcEngine.getInstance( this );
    rtcEngine.setRtcListenerAndHandler( engineEventListener, eventHandler );
    rtcEngine.setImListener( imListener );
    rtcEngine.setInviteListener( inviteListener );
    rtcEngine.setServerAddr( SERVER_ONLINE );
    rtcEngine.setAutoPublishSubscribe( autoPublish, autoSubscribe );
    publishConfig = new PublishConfig();
    rtcEngine.configAutoPublish( publishConfig );
  2. Create or join a channel.

    CreateRoomParams createRoomParams = new CreateRoomParams();
    rtcEngine.createRoom( createRoomParams );
    JoinRoomParams joinRoomParams = new JoinRoomParams();
    rtcEngine.joinRoom( joinRoomParams );
  3. Add a listener for the local and remote views.

    • Local: onCameraPreviewInfo(final ARTVCView view )

    • Remote: void onRemoteViewFirstFrame( final FeedInfo info, final ARTVCView _view )