On this page

CreatePlayer

2026-11-13
POST

https://cloud-player-api.zego.im/

Call this API to create a cloud player. After successful creation, the cloud player will automatically load the passed media resources and publish the stream to the specified room for playback.

Warning

Under the same AppID, a maximum of 50 running (not destroyed) cloud players are allowed to exist simultaneously. If you need to increase the limit, please contact ZEGOCLOUD Technical Support for assistance.

Note
Call frequency limit: 20 times/second

Request

Query Parameters

    Action stringrequired

    Possible values: [CreatePlayer]

    API prototype parameter

    https://cloud-player-api.zego.im?Action=CreatePlayer

    AppId uint32required

    💡Common parameter. Application Id, a unique user credential assigned by ZEGOCLOUD. Can be obtained from ZEGOCLOUD Console.

    SignatureNonce stringrequired

    💡Common parameter. 16-digit hexadecimal random string (hex encoding of 8-byte random number). For the generation algorithm, please refer to Signature Example.

    Timestamp int64required

    💡Common parameter. Current Unix timestamp, unit is seconds. For the generation algorithm, please refer to Signature Example, a maximum error of 10 minutes is allowed.

    SignatureVersion stringrequired

    Possible values: [2.0]

    Default value: 2.0

    💡Common parameter. Signature version number.

    Signature stringrequired

    💡Common parameter. Signature, used to verify the legitimacy of the request. Please refer to Signature Mechanism for generation.

Body

required
    StreamUrl stringrequired

    Possible values: <= 1024 characters

    The address of the media resource, which must be a valid HTTP/HTTPS address with a length within 1024 bytes. Only one parameter can be selected here, where StreamUrl indicates creating a single player, and StreamUrlList indicates creating a list player.

    StreamUrlList string[]

    The address list of media resources, used for continuously playing multiple media resources. Supports up to 100 file addresses with a total byte length not exceeding 50000.

    Note

    This feature is disabled by default. If you need to enable and use it, please contact ZEGOCLOUD Technical Support for configuration.

    Only one parameter can be selected here, where StreamUrl indicates creating a single player, and StreamUrlList indicates creating a list player.

    BackupStreamUrl string

    Possible values: <= 1024 characters

    The backup address of the media resource, which must be a valid HTTP/HTTPS address with a length within 1024 bytes. When the address in the StreamUrl parameter fails to access, the cloud player will try to access the backup address.

    RoomId stringrequired

    Possible values: <= 128 characters

    Publish stream to the specified room ID, with a length within 128 bytes. When calling this API, if the RoomId does not exist, a room will be automatically created.

    StreamId string

    Possible values: <= 256 characters

    The stream ID of the cloud player publishing to the specified room, with a length within 256 bytes, only supporting numbers, English characters, and '-', '_'. Please note that under the same AppID, StreamId must be unique. When this parameter is not filled in, ZEGOCLOUD server will randomly assign an ID.

    PlayerName string

    Possible values: <= 64 characters

    The name of the cloud player, with a length within 64 bytes, default is empty.

    • Under the same AppId, multiple cloud players with empty PlayerName can exist, but multiple running cloud players with duplicate PlayerName are not allowed.
    • The destroyed player name PlayerName can be created and used again, but it is recommended that developers avoid creating players with the same PlayerName.
    VideoOptions object
    Video transcoding parameter configuration. Please note that when this parameter is not filled in, all fields contained in it use default values.
    Width number

    Possible values: >= 1 and <= 3000

    Video width, value range is [1, 3000], unit is px, default value is the width of the original media resource.

    Note

    • When an odd value is passed in the range, it will be automatically rounded up to an even number.
    • When either Width or Height parameter is set to 1, it means audio-only stream publishing.
    Height number

    Possible values: >= 1 and <= 3000

    Video height, value range is [1, 3000], unit is px, default value is the height of the original media resource.

    Note

    • When an odd value is passed in the range, it will be automatically rounded up to an even number.
    • When either Width or Height parameter is set to 1, it means audio-only stream publishing.
    ShortEdge int

    Possible values: >= 0 and <= 2160

    Video short edge length, value range is [0,2160], unit is px. Default value is 0, indicating that the short edge adaptive feature is not enabled.

    Note

    • When an odd value is passed in the range, it will be automatically rounded up to an even number.
    • Once the short edge adaptive feature is enabled, it can only be updated, and cannot be cancelled.
    • When both ShortEdge and Width/Height are set, Width/Height takes precedence.
    • After calculating the short edge, the resolution cannot exceed 4k(3840*2160), otherwise the original media resource width and height will be used.
    VideoBitrate number

    Possible values: >= 1 and <= 50000

    Video bitrate, value range is [1, 50000], unit is kbps, default value is the recommended bitrate given by ZEGOCLOUD based on resolution and frame rate.For example, when the input resolution is 360*640, the VideoBitrate of the output stream is set to 600 kbps.

    VideoCodec number

    Possible values: [0, 2, 3]

    Video encoding format.

    • 0: H264, default value.
    • 2: VP8.
    • 3: H265.
    Fps number

    Possible values: >= 1 and <= 30

    Video frame rate, value range is [1, 30], unit is fps, default value is 15.

    RenderMode number

    Possible values: [0, 1]

    Video fill mode.

    • 0: Fill mode, video is scaled proportionally until the picture is fully displayed in the window, there may be black borders, default value.
    • 1: Crop mode, video is scaled proportionally until it fills the entire window, some parts may be cropped.
    AudioOptions object
    Audio transcoding parameter configuration. Please note that when this parameter is not filled in, all fields contained in it use default values.
    AudioCodec number

    Possible values: [0, 1, 6]

    Audio encoding and sampling rate.

    • 0: AAC-LC, sampling rate: 44100 kHz, default value.
    • 1: HE-AAC, sampling rate: 44100 kHz.
    • 6: OPUS, sampling rate: 48000 kHz.
    AudioBitrate number

    Possible values: >= 1 and <= 192

    Audio bitrate, value range is [1, 192], unit is kbps, default value is 48 kbps.

    SoundChannel number

    Possible values: [1, 2]

    Number of audio channels.

    • 1: Mono, default value.
    • 2: Stereo.
    Volume number

    Possible values: >= 0 and <= 200

    Volume value, range is [0, 200], default value is 100, indicating the original volume of the audio.

    PlayTime number

    Unix timestamp (seconds) when starting to play the online media stream, value range is [CreateTime - 86400, CreateTime + 1800] (CreateTime is the creation time of the cloud player, which will be returned after successfully calling this API. If you need to increase the limit, please contact ZEGOCLOUD Technical Support), default value is 0, indicating that when the cloud player is successfully created, it will automatically start playing the online media stream.

    • When PlayTime = CreateTime, the cloud player will automatically start playing when successfully created.
    • When PlayTime > CreateTime, the cloud player will preload the media resources after successful creation, and start playing at the set PlayTime moment, achieving the effect of scheduled playback.
    • When PlayTime < CreateTime, the cloud player will start playing from the position corresponding to the CreateTime - PlayTime moment after successful creation. For example, when cloud player A encounters an exception during operation, you can create a new cloud player B, set B's PlayTime to the Unix timestamp when A started playing, and when B is successfully created, it can directly start playing from A's current progress.

    For example, if CreateTime is 20:00 in the evening, when PlayTime is 20:00, the cloud player will start playing directly after successful creation; when PlayTime is 20:10 (CreateTime + 600), the cloud player will start loading resources after successful creation and start playing at 20:10; when PlayTime is 19:55 (CreateTime - 300), the cloud player will start playing directly from the 6th minute of the media stream after successful creation.

    RepeatTimes number

    Number of playbacks.

    • 1: Play the media stream 1 time, default value.
    • -1: Automatic loop playback.
    • n: Custom number of times to play the media stream, must be greater than 0.
    SeekTo number

    Specify playback progress (seconds), default value is 0, indicating starting playback from the beginning position.

    MaxIdleTime number

    Possible values: >= 5 and <= 3000

    The maximum duration that the cloud player is in idle state (referring to Status being 2, 5, 6, please refer to the return parameters of Query Cloud Player Task List for details), that is, the maximum duration that the media stream is in a non-playing state. Value range is [5, 3000], unit is seconds, default value is 300 seconds, when greater than 3000, it will be automatically adjusted to 3000.

    • After the idle state exceeds the set MaxIdleTime, the player will be automatically destroyed.
    • If MaxIdleTime is less than 5, ZEGOCLOUD server will automatically adjust it to 5; if it is greater than 600, ZEGOCLOUD server will automatically adjust it to 3000.
    StreamData object
    Data configuration carried by the real-time media stream (such as playback progress information, etc.). This data will be transmitted to the stream player as SEI information along with the video frames. The stream player can obtain this data by listening to callbacks such as onPlayerSyncRecvSEI on the client. The SEI information transmitted by this parameter is in JSON data format by default, and developers can parse it in JSON format. For example, the SEI content is null, where CloudPlayerPlayingProgress represents the current playback progress of the video frame, and 1000 indicates that the current playback progress is 1000ms.
    Enable number

    Possible values: [0, 1]

    Whether to enable StreamData configuration.

    • 0: Not enabled, default value.
    • 1: Enabled.
    Interval number

    Set the sending frequency (milliseconds) of SEI information used to transmit StreamData data, default value is 1000, indicating that 1 SEI information carrying StreamData data is sent every 1 second.

    ExtensionParams object[]
    Extension parameters, set in Key-Value format. This parameter is generally used for unconventional special parameters or some technical previews. Please fill in according to the actual situation. Regular cloud player tasks can ignore it.
  • Array[
  • Key string

    Key value.

    Value string

    Value.

  • ]
  • RoomUserUpdate number

    Possible values: [0, 1]

    When you automatically create a room because the RoomId does not exist when creating a cloud player, whether users entering or leaving the room will trigger the onRoomUserUpdate callback notification on the client of other users in the room.

    • 0: No (default).
    • 1: Yes.

    Note

    If RoomId exists, this parameter is invalid.

    DelayDestroySeconds number

    Possible values: >= 0 and <= 3600

    Delay time for destroying the cloud player, unit is seconds. Range is [0,3600], default value is 0.

    Note

    If you need to adjust the value range of the delay destroy time, please contact ZEGOCLOUD Technical Support.

    CustomUserId string

    Possible values: <= 50 characters

    The suffix of the RTC userId used by the cloud player to join the room. The full userId is cloud_player_ + this field. When this field is empty, playerId is used as the suffix by default, that is, cloud_player_{playerId}. Do not include the cloud_player_ prefix when passing this field.

    Note

    • The length cannot exceed 50 bytes.
    • Only digits, English letters, and the special characters ~!@#$%^&*()_+=-;',.<> and backtick (`) are supported. Spaces are not allowed.
    • Under the same App, the same full RTC userId cannot exist at the same time.
    • This parameter takes effect only when creating a player and cannot be updated after creation.

Responses​

OK
Schema
    Code number

    Error code.

    The following only lists the return codes related to the API business logic. For the complete return codes, please refer to Global Return Codes.

    Return CodeDescriptionHandling Suggestion
    0Success.-
    100000004Signature expired.Please regenerate the signature.
    100000005Signature error.Please confirm whether the parameters for generating the signature are correct.
    350006001API request frequency exceeds the limit.Please confirm the QPS limit of the corresponding API and reduce the request frequency.
    350006002Gateway verification failed.Please contact ZEGOCLOUD Technical Support for assistance.
    350006003Invalid input parameter.Please adjust the value of the corresponding parameter according to the Message prompt.
    350006006Service not activated.Please contact ZEGOCLOUD Technical Support to activate the service permission.
    350006007Cloud player concurrency limit reached.Please confirm whether the number of currently created cloud players exceeds the limit, the default limit is 50.
    350006008A running cloud player with the same name currently exists.Please confirm whether a cloud player with the same PlayerName and running exists.
    350010000System error.Please contact ZEGOCLOUD Technical Support for assistance.
    Message string

    Error description.

    RequestId string

    Request ID.

    Data object
    Returned specific information.
    PlayerId string

    Player unique identifier ID.

    RoomId string

    Room ID.

    StreamId string

    Stream ID.

    CreateTime number

    Player creation time, Unix timestamp, unit: seconds.

Previous

Call API Online

Next

Update a cloud player

On this page

Back to top