Cloud Player
On this page

Implementing a cloud player


Overview

This article introduces how to quickly implement and maintain a cloud-based player based on a server-side API.

Warning

Developers should pay attention to the copyright issues of media resources. Encrypted copyrighted music may fail to play.

Prerequisites

  • Create a project in the ZEGOCLOUD console and apply for a valid AppID. For more details, please refer to How to view project information.
  • Please contact ZEGOCLOUD technical support to enable the permission for cloud player service and configure the relevant callback address to receive event notifications.

Implementation process

1 Create a cloud player

Call the CreatePlayer interface and set the media resource StreamUrl to create a cloud player with the specified RoomId. For more details, please refer to Create a cloud player. After successful creation, the cloud player will automatically load the media resource and start streaming it for playback in the specified room.

Warning

Call all interfaces need to carry common parameters, please refer to Accessing server APIs, signature information please refer to Accessing server APIs - Signature mechanism, and the following is not repeated.

Warning
  • Within the same AppID, a maximum of 50 cloud players can be running (not destroyed) at the same time. If you need to increase this limit, please contact ZEGOCLOUD technical support.
  • When calling the CreatePlayer interface:
    • If the specified RoomId does not exist, it will be automatically created and logged into.
    • If the specified StreamId does not exist, a new stream will be automatically created and pushed into the specified room. If no StreamId is provided, ZEGOCLOUD server will assign a random ID.

After successful creation, the ZEGOCLOUD server will return the PlayerId (unique identifier) of the player. At the same time, the player will load the media resources and start streaming to the room with the specified RoomId for playback.

2 Update a cloud player

During the process of playing media resources in a room, developers can call the UpdatePlayer interface at any time to set PlayerId (unique identifier), AudioOptions (audio transcoding parameter configuration), and VideoOptions (video transcoding parameter configuration) to update the specified cloud player. For more details, please refer to Update a cloud player.

Through the UpdatePlayer interface, developers can also implement functions such as pausing playback, seeking progress, and changing the media resource being played.

3 Destroy a cloud player

Developers can call the DeletePlayer interface according to their own business scenarios, set the PlayerId (unique identifier), and destroy the specified cloud player. For more details, please refer to Destroy a cloud player.

After a successful interface call, the media resources will automatically stop playing, and the corresponding live streaming will be terminated.

Common Functions

Query the task list of a cloud player

Developers can use the DescribePlayers interface to query the task list and detailed information of all cloud players in a specified room (RoomId), or to query the relevant information of a specific player (PlayerId). For more information, please refer to Query the task list of a cloud player.

When a cloud player is created, updated, or destroyed, the related status changes will be notified through the callback address configured in the Prerequisites. Developers can choose to listen to the relevant callback events according to their own business scenarios. For more information, please refer to Callback.

Previous

Release notes

On this page

Back to top