CreatePlayer
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.
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.
Request
Query Parameters
Possible values: [CreatePlayer]
API prototype parameter
https://cloud-player-api.zego.im?Action=CreatePlayer
💡Common parameter. Application Id, a unique user credential assigned by ZEGOCLOUD. Can be obtained from ZEGOCLOUD Console.
💡Common parameter. 16-digit hexadecimal random string (hex encoding of 8-byte random number). For the generation algorithm, please refer to Signature Example.
💡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.
Possible values: [2.0]
Default value: 2.0
💡Common parameter. Signature version number.
💡Common parameter. Signature, used to verify the legitimacy of the request. Please refer to Signature Mechanism for generation.
- application/json
Body
required
- 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.
- 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.
- 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.
- 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.
- 0: H264, default value.
- 2: VP8.
- 3: H265.
- 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.
- 0: AAC-LC, sampling rate: 44100 kHz, default value.
- 1: HE-AAC, sampling rate: 44100 kHz.
- 6: OPUS, sampling rate: 48000 kHz.
- 1: Mono, default value.
- 2: Stereo.
- 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 - PlayTimemoment 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. - 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.
- 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.
- 0: Not enabled, default value.
- 1: Enabled.
- Array[
- ]
- 0: No (default).
- 1: Yes.
- 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.
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.
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.
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.
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.
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.
Possible values: <= 64 characters
The name of the cloud player, with a length within 64 bytes, default is empty.
VideoOptions object
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
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
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
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.
Possible values: [0, 2, 3]
Video encoding format.
Possible values: >= 1 and <= 30
Video frame rate, value range is [1, 30], unit is fps, default value is 15.
Possible values: [0, 1]
Video fill mode.
AudioOptions object
Possible values: [0, 1, 6]
Audio encoding and sampling rate.
Possible values: >= 1 and <= 192
Audio bitrate, value range is [1, 192], unit is kbps, default value is 48 kbps.
Possible values: [1, 2]
Number of audio channels.
Possible values: >= 0 and <= 200
Volume value, range is [0, 200], default value is 100, indicating the original volume of the audio.
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.
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.
Number of playbacks.
Specify playback progress (seconds), default value is 0, indicating starting playback from the beginning position.
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.
StreamData object
null, where CloudPlayerPlayingProgress represents the current playback progress of the video frame, and 1000 indicates that the current playback progress is 1000ms.Possible values: [0, 1]
Whether to enable StreamData configuration.
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[]
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.Key value.
Value.
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.
Note
If RoomId exists, this parameter is invalid.
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.
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
Responses
- 200
- application/json
- Schema
- Example (from schema)
Schema
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 Code | Description | Handling Suggestion |
|---|---|---|
| 0 | Success. | - |
| 100000004 | Signature expired. | Please regenerate the signature. |
| 100000005 | Signature error. | Please confirm whether the parameters for generating the signature are correct. |
| 350006001 | API request frequency exceeds the limit. | Please confirm the QPS limit of the corresponding API and reduce the request frequency. |
| 350006002 | Gateway verification failed. | Please contact ZEGOCLOUD Technical Support for assistance. |
| 350006003 | Invalid input parameter. | Please adjust the value of the corresponding parameter according to the Message prompt. |
| 350006006 | Service not activated. | Please contact ZEGOCLOUD Technical Support to activate the service permission. |
| 350006007 | Cloud player concurrency limit reached. | Please confirm whether the number of currently created cloud players exceeds the limit, the default limit is 50. |
| 350006008 | A running cloud player with the same name currently exists. | Please confirm whether a cloud player with the same PlayerName and running exists. |
| 350010000 | System error. | Please contact ZEGOCLOUD Technical Support for assistance. |
Error description.
Request ID.
Data object
Player unique identifier ID.
Room ID.
Stream ID.
Player creation time, Unix timestamp, unit: seconds.
{
"Code": 0,
"Message": "succeed",
"RequestId": "abcd123",
"Data": {
"PlayerId": "XXXXXXXXXXXX",
"RoomId": "room_12",
"StreamId": "stream",
"CreateTime": 1681221508
}
}{
"Code": 0,
"Message": "succeed",
"RequestId": "abcd123",
"Data": {
"PlayerId": "XXXXXXXXXXXX",
"RoomId": "room_12",
"StreamId": "stream",
"CreateTime": 1681221508
}
}