RTS live playback

Updated at:
Copy as MD

Real-Time Streaming (RTS) is a value-added feature of ApsaraVideo Live that delivers live streaming with millisecond-level latency for millions of concurrent users. By reducing the 3- to 6-second latency of traditional live streaming, RTS enables ultra-low latency, smooth, and instant playback through the ApsaraVideo Player SDK.

Important

For more information about features, API documentation, and the FAQ, see Android player.

RTS playback

The ApsaraVideo Player SDK for Android integrates the native RTS SDK for low-latency live streaming. For more information, see Implement RTS stream pulling on Android.

For a code example, see the RTS ultra-low latency live playback (RtsLiveStream) module in API-Example. This Java-based sample project demonstrates how to integrate the core features of the ApsaraVideo Player SDK for Android.

RTS resolution switching

Note
  • This feature supports ApsaraVideo Live playback URLs and transcoded stream URLs. Both default and custom transcoding are supported. For more information about live stream transcoding, see Transcoding management. For more information about how to generate streaming URLs, see Generate streaming URLs.

  • Resolution switching is supported for live streams that use the RTS and HTTP-FLV protocols.

  • The group of pictures (GOP) size of the ingested stream must be 1 second or 2 seconds. A larger GOP size may cause playback to skip when you switch streams.

  • For the streaming domain, enable the Output RTMP timestamps during FLV playback and Output RTMP timestamps after upstream interruption options. For the transcoding configuration, enable the Source timestamp and Source keyframe options. Otherwise, stream switching may stutter or fail. To enable these options, submit a ticket.

  • If you switch to a stream URL that does not meet these requirements, the switch fails.

Switch resolutions

To switch resolutions, call the switchStream method and pass the URL for the new resolution.

// Start playback
aliPlayer.setUrlSource(oldUrl);
aliPlayer.prepare();
aliPlayer.start();

// Switch to another URL during playback
aliPlayer.switchStream(newUrl);

Resolution switch notifications

The following callbacks are triggered when a resolution switch succeeds or fails.

aliPlayer.setOnStreamSwitchedListener(new IPlayer.OnStreamSwitchedListener() {
    @Override
    public void onSwitchedSuccess(String url) {
        Log.i("SwitchStream", "switch success, url = " + url);
    }

    @Override
    public void onSwitchedFail(String url, ErrorInfo errorInfo) {
        Log.i("SwitchStream", "switch failed, url = " + url + ", error=" + errorInfo.getMsg());
    }
});