logo
Video Call
On this page

Instant Startup Solution for Show Live Streaming

2024-09-27

Introduction

In the show live streaming scenario, instant startup is achieved by optimizing the audience's stream playing speed. Compared with the normal stream playing process, the advantage of instant startup stream playing is that it does not rely on the successful login room status. It initiates stream playing while initiating login room to speed up stream playing. The following is a comparison between normal stream playing and instant startup stream playing:

Prerequisites

Before implementing the instant startup solution for show live streaming, ensure that:

  • A project has been created in the ZEGOCLOUD Console, and valid AppID and AppSign have been obtained. For details, please refer to Console - Project Information.

  • ZEGO Express SDK has been integrated into the project, and basic audio and video streaming functionality has been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementation Process.

  • Before playing streams, the stream ID has been obtained, and it must be ensured that the host is in the broadcasting status. The broadcasting status is managed by the business side.

    Note

    The playing end needs to know the stream ID in advance. Usually, the stream ID is spliced according to fixed rules (such as splicing in the roomId_userId manner), or the room information obtained in advance by the business side adds the stream ID parameter.

Implementation Process

Initialization

For details, please refer to the "Initialization" section in Quick Start - Implementation Process.

ZegoEngineProfile profile;
// AppID and AppSign are assigned to each App by ZEGO; for security reasons, it is recommended to store AppSign in the App's business backend and obtain it from the backend when needed
profile.appID = appID;
profile.appSign = appSign;
// Specify to use the live streaming scenario (please fill in the scenario suitable for your business according to the actual situation)
profile.scenario = ZegoScenario::ZEGO_SCENARIO_BROADCAST;
// Create engine instance
auto engine = ZegoExpressSDK::createEngine(profile, nullptr);

Login room

For details, please refer to the "Login room" section in Quick Start - Implementation Process.

// Create user object
ZegoUser user("user1", "user1");
// Only by passing in ZegoRoomConfig with the "isUserStatusNotify" parameter set to "true" can you receive the onRoomUserUpdate callback.
ZegoRoomConfig roomConfig;
//If you use appsign for authentication, the token parameter does not need to be filled; if you need to use a more secure authentication method: token authentication.
// roomConfig.token = "xxxx";
roomConfig.isUserStatusNotify = true;
// Login room
engine->loginRoom(roomID, user, roomConfig, [=](){
    // (Optional callback) Login room result. If you only care about the login result, just pay attention to this callback
});

Audience plays stream

After logging in to the room, without relying on the successful login room status, you can initiate stream playing while initiating login room to speed up stream playing and achieve the instant startup effect.

Note
  • It is recommended that developers use Ultra-Low Latency Live Streaming (L3) for stream playing to achieve a higher quality live streaming experience. For details, please refer to Ultra-Low Latency Live Streaming.
  • When developers use ZEGO-configured CDN for direct publishing, they can directly play streams through streamID. Please refer to "Playing stream" in Quick Start - Implementing Video Call.
  • When developers use third-party CDN for direct publishing, they can play streams through URL. Please refer to Playing Stream by URL.
// Start playing stream, set the remote playing rendering view canvas, and use the SDK's default mode for the view mode, scaling proportionally to fill the entire View
ZegoCanvas canvas((void*)view);
// After filling in the url parameter, the sdk will pull the audio and video stream from the url, but still needs to pass a unique streamID to the SDK, which will use this streamID to identify the stream internally
// For specific stream playing methods, please refer to L3 stream playing, RTC stream playing, CDN stream playing
engine->startPlayingStream(streamID, &canvas, config);

Previous

Switching from CDN Stream Playing to Co-hosting Scenario

Next

FAQ

On this page

Back to top