Audio and video preview
Audio and video preview lets CDN edge nodes return a time-limited portion of an audio or video file instead of the full file. This is used in video-on-demand (VOD) services to give non-premium users a free trial before they subscribe.
Supported formats
| Format | Support | Notes |
|---|---|---|
| TS | Supported | Configure using this feature |
| MP3 | Supported | Configure using this feature |
| FLV | Not supported | Use video seeking with the end parameter instead |
| MP4 | Not supported | Use video seeking with the end parameter instead |
| HLS | Not natively supported | Submit a ticket to request configuration |
How it works
When a client sends a request with a preview duration parameter, the CDN edge node returns only the specified portion of the file. For example:
http://example.com/sample.ts?free_time=15This returns the first 15 seconds of sample.ts. The parameter name and value you configure in the console must match exactly what your client sends in the request URL.
Parameter behavior:
| Scenario | Behavior |
|---|---|
| Parameter name set, no default value configured | Edge node returns the duration specified in each incoming request |
| Client requests longer than the total preview length | The total preview length takes effect. To avoid a shorter preview than intended, request slightly longer than the target — for example, request 15 seconds to preview 13 seconds of content |
Enable audio and video preview
Procedure
Log on to the .
In the left navigation pane, click Domain Names.
On the Domain Names page, find the target domain name and click Manage in the Actions column.
In the domain's navigation pane, click Video.
In the Audio/video Preview section, turn on Audio/video Preview and set Custom Preview Parameter. Set Custom Preview Parameter to the query parameter name your client uses in requests. The value is the preview duration in seconds. For example, if you set Custom Preview Parameter to
free_timeand a client sendsfree_time=15, the edge node returns 15 seconds of the requested file.
Click OK.
What's next
To configure preview for FLV or MP4 files, see Configure video seeking.