All Products
Search
Document Center

ApsaraVideo Live:ApsaraVideo Player SDK for Flutter

Last Updated:Mar 31, 2026

The ApsaraVideo Player SDK for Flutter provides an efficient solution for integrating audio and video features into mobile applications, supporting both live streaming and video-on-demand (VOD). This topic describes the live streaming playback feature of the ApsaraVideo Player SDK for Flutter.

Standard live streaming playback

  1. Integrate the SDK.

    For more information, see Integrate ApsaraVideo Player SDK for Flutter.

  2. Implement live streaming playback.

    1. Get started.

      To implement basic features, see Getting started.

    2. Set the live stream source.

      The ApsaraVideo Player SDK for Flutter supports only the UrlSource method.

      UrlSource

      To play a live stream using the UrlSource method, set the setUrl property to the streaming URL. The URL can be a third-party streaming URL or a streaming URL from ApsaraVideo Live.

      You can generate streaming URLs in the ApsaraVideo Live console using the URL generator.

      void onViewPlayerCreated(viewId) async {
        // Set the rendering view for the player.
        fAliplayer.setPlayerView(viewId);
        // Set the playback source.
        switch (_playMode) {
          // UrlSource playback method.
          case ModeType.URL:
            this.fAliplayer.setUrl("Enter the streaming URL"); // It can be a third-party streaming URL or a streaming URL from ApsaraVideo Live.
            break;
          default:
        }
      }

RTS playback

Note
  • Integrate the native SDK for Android or iOS.

    For Android integration, add the dependencies to the build.gradle file, as shown in the following example.

    dependencies{
        def player_sdk_version = "7.2.0"
        def rts_sdk_version = "7.2.0"
        
        // The bridge layer between the player and RTS (AlivcArtc). The version number must match the player's version number. This must be integrated with the RTS component.
        implementation 'com.aliyun.sdk.android:AlivcArtc:$player_sdk_version'
        // The RTS component. It has an independent version number.
        implementation 'com.aliyun.rts.android:RtsSDK:$rts_sdk_version'
    }

    For iOS integration, add the dependencies to the Podfile file, as shown in the following example.

    # player_sdk_version is the version number of the ApsaraVideo Player SDK for iOS, for example, 7.2.0.
    player_sdk_version = '7.2.0'
    # rts_sdk_version is the version number of the RTS SDK, which is independent, for example, 7.2.0.
    rts_sdk_version = '7.2.0'
    
    target 'Runner' do
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
      # The bridge layer between the player and RTS (AlivcArtc). The version number must match the player's version number. This must be integrated with the RTS component.
      pod 'AliPlayerSDK_iOS_ARTC', player_sdk_version 
      # The RTS component.
      pod 'RtsSDK', rts_sdk_version  
    
    end

To play an ApsaraVideo Real-Time Communication (ARTC) stream, you must import the RTS dependencies during integration. For Android, you must also call FlutterAliPlayerFactory.loadRtsLibrary(); to load the RTS SDK dynamic library before you create the player. The following example shows this process:

  1. Configure the pubspec.yaml file.

    name: your_project
    description: A new Flutter project.
    version:  1.0.0+1
    
    # The following line prevents the package from being accidentally published to
    # pub.dev using `pub publish`. This is preferred for private packages.
    publish_to: 'none' # Remove this line if you want to publish to pub.dev
    
    environment:
      sdk: ">=2.15.0 <4.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
      // Add flutter_aliplayer.
      flutter_aliplayer: "7.3.1"
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    
    # The following section is specific to Flutter.
    flutter:
    
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
  2. Load the RTS SDK.

    Note
    1. If you use ApsaraVideo Player for Android V7.3.1 or earlier, you must manually load the RTS SDK.

    2. If useAIOFramework=true, the all-in-one ApsaraVideo MediaBox SDK is used. Otherwise, the ApsaraVideo Player SDK and the RTS SDK are used. The default value of this property is false.

    3. Use the latest SDK versions:

      1. For the ApsaraVideo MediaBox SDK, see Integrate ApsaraVideo MediaBox SDK for Android and Integrate ApsaraVideo MediaBox SDK for iOS.

      2. For the ApsaraVideo Player SDK, see Download ApsaraVideo Player SDK.

      3. For the RTS component, see Implement RTS stream pulling on Android and Implement RTS-based stream pulling on iOS.

    dependencies {
        // Define the SDK kernel.
        def useAIOFramework = false
    
        // Define the SDK versions.
        // ApsaraVideo MediaBox SDK.
        def aio_sdk_version = "7.1.0"
        // ApsaraVideo Player SDK.
        def player_sdk_version = "7.2.0"
        // RTS component.
        def rts_sdk_version = "7.2.0"
    
        // Select the SDK based on the value of useAIOFramework.
        if (useAIOFramework) {
            // ApsaraVideo MediaBox SDK (interactive version): Push SDK (including RTS and ARTC co-streaming) + ApsaraVideo Player SDK.
            implementation "com.aliyun.aio:AliVCSDK_InteractiveLive:$aio_sdk_version"
        } else {
            // ApsaraVideo Player SDK.
            implementation "com.aliyun.sdk.android:AliyunPlayer:$player_sdk_version-full"
            implementation "com.aliyun.sdk.android:AlivcArtc:$player_sdk_version"
            implementation "com.aliyun.rts.android:RtsSDK:$rts_sdk_version"
        }
    
        implementation 'com.google.code.gson:gson:2.10.1'
    }
    

    Manually load the RTS SDK.

    FlutterAliPlayerFactory.loadRtsLibrary(true);
  3. Play the video.

    FlutterAliplayer player = FlutterAliPlayerFactory.createAliPlayer();
    player.setUrl("artc://xxxx");
    
    player.prepare();
    player.play();