All Products
Search
Document Center

GetPlayInfo

Last Updated: Jul 11, 2019

Description

You can call this operation to directly obtain the playback URL of a media (such as video or audio) file based on the video ID.

Request parameters


Name Type Required Description
Action String Yes The operation that you want to perform. Set this parameter to GetPlayInfo.
VideoId String Yes The ID of the video.
Formats String No The format of the media stream. Separate multiple formats with commas (,). Valid values:
  • mp4
  • m3u8
  • mp3
  • mpd (This value is valid only when the PackageType parameter is set to DASHPackage. For more information, see the description of the Container parameter in the TranscodeTemplate structure.)
Streams in all formats are obtained by default.
AuthTimeout Long No The expiration time of the playback URL. Unit: seconds.

If you set the OutputType parameter to cdn:
  • The playback URL expires after the specified time only if URL signing is enabled. Otherwise, the playback URL is permanently valid.
  • Minimum value: 1.
  • Maximum value: unlimited.
  • Default value: the default validity period set in URL signing.
If you set the OutputType parameter to oss:
  • The playback URL expires after the specified time only if the Permissions parameter is set to Private Read and Write on the Storage page in the ApsaraVideo for VOD console. Otherwise, the playback URL is permanently valid.
  • Minimum value: 1.
  • Maximum value: 2592000 (30 days). The maximum value is limited to reduce security risks of the origin.
  • Default value: 3600.
StreamType String No The type of the media stream. Separate multiple types with commas (,). Valid values:
  • video
  • audio
Streams of all types are obtained by default.
Definition String No The definition of the media stream. Separate multiple definitions with commas (,). Valid values:
  • FD: indicates low definition.
  • LD: indicates standard definition.
  • SD: indicates high definition.
  • HD: indicates ultra high definition.
  • OD: indicates original quality.
  • 2K: indicates 2K resolution.
  • 4K: indicates 4K resolution.
  • SQ: indicates standard sound quality.
  • HQ: indicates high sound quality.
  • AUTO: indicates the adaptive bitrate. This value is valid only when the PackageSetting parameter in the TranscodeTemplate structure is configured. For more information, see the description of the PackageSetting parameter in the TranscodeTemplate structure.
Streams of all definitions are obtained by default.
ResultType String No The type of the returned data. Valid values:
  • Single: indicates that only one latest transcoded stream is returned for each definition and format.
  • Multiple: indicates that all transcoded streams are returned for each definition and format.
Default value: Single.
OutputType String No The type of the output URL. Valid values:
  • oss
  • cdn
Default value: cdn. Note: An OSS URL can be used to play media streams in .mp4 format only.
PlayConfig PlayConfig No The custom playback configuration. The value is a JSON-formatted string. If multiple playback domain names are configured, you can specify a domain name.
ReAuthInfo ReAuthInfo No The CDN reauthentication configuration. The value is a JSON-formatted string. If CDN reauthentication is enabled, you can use this parameter to set the uid and rand fields for URL signing. For more information, see URL signing.

Response parameters


Name Type Description
RequestId String The ID of the request.
VideoBase VideoBase The basic information about a media file.
PlayInfoList PlayInfo[] The media stream information list.

API examples

Sample request

http://vod.cn-shanghai.aliyuncs.com/?Action=GetPlayInfo&VideoId=93ab850b4f6f44eab54b6e91d24d81d4&Format=JSON&<Common request parameters>

Note: For more information about common request parameters, see Common parameters.

Sample response

JSON format

{
     "RequestId": "25818875-5F78-4A13-BEF6-D7393642CA58",
     "VideoBase": {
         "VideoId": "93ab850b4f6f44eab54b6e91d24d81d4",
         "Title": "ApsaraVideo for VOD",
         "Duration": "15.0",
         "CoverURL": "http://image.example.com/sample.jpg?auth_key=2333232-atbb667",
         "Status": "Normal",
         "MediaType": "video",
         "OutputType": "cdn",
         "CreationTime": "2017-06-26T05:38:48Z"
      },
      "PlayInfoList": {
        "PlayInfo":[
          {
          "Bitrate": "925.0",
          "Definition": "LD",
          "Duration": "15.0",
          "Encrypt": 0,
          "PlayURL": "http://vod.aliyunsample.com/ABEBDE15CC479FD4D1329/62cb3151eba5289f8e2da3b55bc57c49.mp4?auth_key=122123-323232abbb",
          "Format": "mp4",
          "StreamType": "video",
          "Fps": "30.0",
          "Height": 960,
          "Size": 1815321,
          "Width": 540,
          "JobId":"23ef850b4f6f44eab54b6e91d24d8123",
          "WatermarkId": "c169d97d995040d6af5b815dfff14e3f",
          "Status":"Normal",
          "CreationTime":"2018-07-04T06:36:56Z",
          "ModificationTime":"2018-07-04T06:37:13Z"
        },
        {
          "Bitrate": "1575.0",
          "Definition": "SD",
          "Duration": "15.0",
          "Encrypt": 0,
          "PlayURL": "http://vod.aliyunsample.com/ABEBDE15CC479FD4D1329/52a53151eba5226f8e2da3b55bc57c49.m3u8?auth_key=abdf2123-6783232accc",
          "Format": "m3u8",
          "StreamType": "video",
          "Fps": "30.0",
          "Height": 960,
          "Size": 3090951,
          "Width": 540,
          "JobId":"23ef850b4f6f44eab54b6e91d24d8456",
          "WatermarkId": "c169d97d995040d6af5b815dfff14e3f",
          "Status":"Invisible",
          "CreationTime":"2018-07-04T06:36:56Z",
          "ModificationTime":"2018-07-04T06:37:13Z"
        }
        ]
      }
    }

Error codes

This operation also returns common errors. For more information about errors common to all operations, see common errors.


Error code Error message HTTP status code Description
Forbidden.IllegalStatus Status of the video is illegal. Current Status is %s. 403 The error message returned because the video status is invalid, where %s indicates the current video status. Only videos in the Normal status can be played.
InvalidVideo.NotFound The video does not exist. 404 The error message returned because the specified video does not exist.
InvalidVideo.NoneStream The video has no stream to play for the request parameter 'Formats : mp4, Definition : LD, StreamType : video'. 404 The error message returned because no transcoded stream file that meets the specified filter criteria is found. Check whether the Transcoding configuration matches the filter criteria.
Forbidden.AliyunVoDEncryption Currently only the AliyunVoDEncryption stream exists, you must use the Aliyun player to play or set the value of ResultType to Multiple. 403 The error message returned because only transcoded stream files encrypted by the Alibaba Cloud video encryption service exist. You must use ApsaraVideo Player to play the files or set the ResultType parameter to Multiple.

SDK examples

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