Queries the credential required for media playback.

Description

  • You can call this operation to obtain a playback credential when you use ApsaraVideo Player SDK to play a media file based on PlayAuth. The credential is used to obtain the playback URL.
  • You cannot obtain the playback URL of a video by using a credential that has expired. A new credential is required.

QPS limit

You can call this operation up to 360 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limit.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes GetVideoPlayAuth

The operation that you want to perform. Set the value to GetVideoPlayAuth.

VideoId String Yes dfde02284a5c46622a097adaf44a****

The ID of the audio or video file. You can use one of the following methods to obtain the ID of the file:

  • Log on to the ApsaraVideo VOD console. In the left-side navigation pane, choose Media Files > Audio/Video. On the Video and Audio page, view the ID of the audio or video file. This method is applicable to files that are uploaded by using the ApsaraVideo VOD console.
  • Obtain the value of the VideoId parameter when you call the CreateUploadVideo operation to upload files.
  • Obtain the value of the VideoId parameter by calling the SearchMedia operation. This method is applicable to files that have been uploaded.
AuthInfoTimeout Long No 100

The time when the playback credential expires. Unit: seconds. You cannot obtain the playback URL of a video by using a credential that has expired. A new credential is required.

  • Default value: 100.
  • Valid values: 100 to 3000.
ApiVersion String No 1.0.0

The API version number. Set the value to 1.0.0.

Response parameters

Parameter Type Example Description
PlayAuth String sstyYuew6789000000xtt7TYUh****

The credential for video or audio playback.

RequestId String E4EBD2BF-5EB0-4476-8829-9D94E1B1****

The ID of the request.

VideoMeta Object

The metadata of the audio or video file.

Status String Normal

The status of the audio or video file. For more information about the value range and description, see the Status table.

Duration Float 120.0

The duration of the audio or video file. Unit: seconds.

Title String ApsaraVideo VOD

The title of the audio or video file.

VideoId String dfde02284a5c46622a097adaf44a****

The ID of the audio or video file.

CoverURL String https://example.aliyundoc.com/****.jpg

The thumbnail URL of the audio or video file.

Examples

Sample requests

http(s)://vod.cn-shanghai.aliyuncs.com/?Action=GetVideoPlayAuth
&VideoId=dfde02284a5c46622a097adaf44a****
&AuthInfoTimeout=100
&ApiVersion=1.0.0
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<GetVideoPlayAuthResponse>
    <PlayAuth>sstyYuew6789000000xtt7TYUh****</PlayAuth>
    <RequestId>E4EBD2BF-5EB0-4476-8829-9D94E1B1****</RequestId>
    <VideoMeta>
        <Status>Normal</Status>
        <Duration>120</Duration>
        <Title>ApsaraVideo VOD</Title>
        <VideoId>dfde02284a5c46622a097adaf44a****</VideoId>
        <CoverURL>https://example.aliyundoc.com/****.jpg</CoverURL>
    </VideoMeta>
</GetVideoPlayAuthResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "PlayAuth" : "sstyYuew6789000000xtt7TYUh****",
  "RequestId" : "E4EBD2BF-5EB0-4476-8829-9D94E1B1****",
  "VideoMeta" : {
    "Status" : "Normal",
    "Duration" : 120,
    "Title": "ApsaraVideo VOD",
    "VideoId" : "dfde02284a5c46622a097adaf44a****",
    "CoverURL" : "https://example.aliyundoc.com/****.jpg"
  }
}

Error codes

For a list of error codes, visit the API Error Center.

Common errors

The following table describes the common errors that this operation can return.

Error code

Error message

HTTP status code

Description

Forbidden.IllegalStatus

Status of the video is illegal.

403

The error message returned because the video status is invalid.

InvalidVideo.NotFound

The video does not exist.

404

The error message returned because the video does not exist.

MissingVideoId

VideoId is mandatory for this action.

400

The error message returned because the VideoId parameter is not specified.

Sample code of SDKs for various languages

We recommend that you use a server-side SDK to call this operation. For more information about the sample code that is used to call this operation in various languages, see the following topics: