This topic describes the properties, methods, and events supported by Aliplayer.
If you encounter issues while using Aliplayer, see Web Player FAQ or Self-troubleshooting for Playback Errors.
Properties
When initializing Aliplayer, you can set multiple properties. These properties include license authorization, media source information, player UI settings, and playback behavior.
Name | Type | Description |
id | String | The DOM element ID of the outer container for the player. |
source | String | When using URL-based playback, specify the video URL with this property. Note
|
vid | String | The media ID for the ApsaraVideo Media Processing service. |
playauth | String | The playback credential. For instructions on obtaining a playback credential, see Obtain a Playback Credential. |
customVodServer | String | A custom domain for VOD proxy (supported in VidAuth playback mode version 2.32.0 and later). You must deploy a dedicated request proxy service. When the default VOD domain (*.aliyuncs.com) is unreachable, the player automatically falls back to your proxy service. This avoids ISP hijacking and improves playback stability and success rate. |
playConfig | JSON | Custom settings used when playing with Vid (VidAuth or VidSts). These pass through to the VOD API. For supported fields and parameter descriptions, see Custom PlayConfig Settings for Media Playback. Example value: |
authTimeout | Number | The validity period of the video playback URL obtained using Vid (VidAuth or VidSts). Unit: seconds. Default: 7200. Ensure this value exceeds the actual video duration to prevent the playback URL from expiring before playback finishes. |
height | String | The player height. Valid values:
|
width | String | The player width. Valid values:
|
autoSize | Boolean | String | Automatically adjust the player size to fit the video content. Valid values: 'height' or 'width'. For example, set width: '500px' and autoSize: 'height'. The player keeps a fixed width of 500px and adjusts its height based on the video's aspect ratio. Or set height: '500px' and autoSize: 'width'. The player keeps a fixed height of 500px and adjusts its width based on the video's aspect ratio. Note: autoSize: true equals autoSize: 'height'. Height auto-sizing is the default. |
videoWidth | String | The video width. For more information, see Set Display Mode. |
videoHeight | String | The video height. For more information, see Set Display Mode. |
preload | Boolean | The player loads automatically. |
cover | String | The default cover image for the player. Enter a valid image URL. This setting takes effect only when autoplay is set to false. |
isLive | Boolean | Indicates whether the content is live streaming. When enabled, users cannot drag the progress bar. Default: false. Set to true for live streams. |
autoplay | Boolean | Enable autoplay for the player. Autoplay fails on mobile devices. Valid values:
Note Due to browser restrictions, autoplay may fail in the Web Player SDK. For details, see Advanced Features. |
autoplayPolicy | Object | The player supports an adaptive policy for muted autoplay. This property takes effect only when Note
|
rePlay | Boolean | Enable automatic loop playback. |
useH5Prism | Boolean | Use the HTML5 player. |
playsinline | Boolean | Enable inline playback for HTML5. Some Android browsers do not support this. |
skinRes | Url | The skin image URL. We do not recommend changing this field. To customize the skin, see Customize the Player Skin. |
skinLayout | Array | Boolean | Configure the layout of UI components. Omit this property to use the default layout. Set to false to hide all UI components. For more information, see Configure the skinLayout Property. |
skinLayoutIgnore | Array | List of UI components to hide. See VOD Component Parameter Reference for component names. Example configuration: Note skinLayoutIgnore takes precedence over skinLayout. |
controlBarVisibility | String | Control panel implementation. Valid values include the following:
|
showBarTime | Number | Time in milliseconds before the control bar hides automatically. |
enableSystemMenu | Boolean | Enable the system right-click menu. Default: false. |
format | String | Specify the format of the playback URL. Valid values:
Default: empty. |
mediaType | String | Specify whether to return audio or video. Supported only when using vid-based playback. Default: video. Valid values:
|
qualitySort | String | Specify the sorting order. Supported only when using Vid + PlayAuth playback. Valid values:
Default: asc. |
definition | String | Define which video definitions to display. Separate multiple definitions with commas (,). Example: 'FD,LD'. This is a subset of definitions available for the specified vid. Valid values:
|
defaultDefinition | String | Set the default video definition. This must be one of the definitions available for the specified vid. Valid values:
|
autoPlayDelay | Number | Delay before playback starts. Unit: seconds. |
language | String | Set the language for internationalization. Default: zh-cn. If omitted, the browser language is used. Valid values:
|
languageTexts | JSON | Custom internationalization text in JSON format. Keys must match the language property value. Example: {jp:{Play:"Play"}}. For a complete list of keys, see JSON Structure. |
snapshotWatermark | Object | Configure screenshot watermarks for HTML5 players. |
useHlsPluginForSafari | Boolean | Enable the HLS plugin for Safari browsers, except Safari 11. Valid values:
|
enableStashBufferForFlv | Boolean | Enable playback caching for FLV in HTML5 players. Applies only to live streaming. Valid values:
|
stashInitialSizeForFlv | Number | Initial cache size for FLV in HTML5 players. Applies only to live streaming. Default: 32 KB. A smaller value improves startup speed. However, if too small, playback may stutter after a short time. |
loadDataTimeout | Number | Time in seconds before prompting the user to switch to a lower definition due to buffering. Default: 20. |
waitingTimeout | Number | Maximum buffering timeout. An error message appears if this time is exceeded. Unit: seconds. Default: 60. |
diagnosisButtonVisible | Boolean | Show the diagnosis button. Valid values:
|
disableSeek | Boolean | Disable seeking with the progress bar. Valid values:
|
encryptType | Number | Enable Alibaba Cloud video encryption (private encryption). Default: 0. Valid values:
Note
|
progressMarkers | Array | An array of progress marker objects. For more information, see Progress Bar Markers. |
vodRetry | Number | Number of retries for VOD playback failures. Default: 3. |
liveRetry | Number | Number of retries for live streaming playback failures. Default: 5. |
hlsFrameChasing | Boolean | Enable frame chasing for HLS live streaming. Valid values:
Note Only Web Player SDK versions earlier than 2.21.0 support setting this parameter. For version 2.21.0 and later, to enable frame synchronization in HLS live streaming mode, refer to the |
chasingFirstParagraph | Number | Duration of the first frame-chasing segment. Unit: seconds. Default: 20. Note You can set this parameter only in Web Player SDK versions earlier than 2.21.0. For version 2.21.0 and later, to set frame synchronization in HLS live streaming mode, see the |
chasingSecondParagraph | Number | Duration of the second frame-chasing segment. Unit: seconds. Default: 40. Note Only Web Player SDK versions earlier than 2.21.0 support setting this parameter. For versions 2.21.0 and later, to set frame synchronization in HLS live streaming mode, see the |
chasingFirstSpeed | Number | Playback speed for the first frame-chasing segment. Default: 1.1×. Note Only Web Player SDK versions earlier than 2.21.0 support configuring this parameter. For versions 2.21.0 and later, to configure frame synchronization in HLS live streaming mode, see the |
chasingSecondSpeed | Number | Playback speed for the second frame-chasing segment. Default: 1.2×. Note Only Web Player SDK versions below 2.21.0 support setting this parameter. For versions 2.21.0 and later, to configure frame synchronization in HLS live streaming mode, see the |
hlsOption.maxLiveSyncPlaybackRate | Number | Set the playback speed for frame chasing in HLS live streaming. Default: 1 (no frame chasing).
Note This parameter is supported only in Web Player SDK versions 2.21.0 and later. |
flvFrameChasing | Boolean | Enable frame chasing for FLV live streaming. Valid values:
Default: false. |
keyShortCuts | Boolean | Enable keyboard shortcuts. Valid values:
Default: false. Note Arrow keys (left/right) control fast forward and rewind. Arrow keys (up/down) control volume. Spacebar toggles play/pause. |
keyFastForwardStep | Number | Time interval for fast forward and rewind. Unit: seconds. Default: 10. |
rtsFallback | Boolean | When the browser does not support RTS or RTS stream pulling fails, the player automatically falls back to FLV or HLS. It prefers FLV for lower latency. If the browser does not support FLV, it falls back to HLS. This feature is enabled by default. To disable it, set this parameter to false. |
rtsFallbackType | String | Specify the protocol to fall back to from RTS. Valid values: HLS or FLV. By default, the player selects automatically, preferring FLV for lower latency. If the browser does not support FLV, it falls back to HLS. |
rtsFallbackSource | String | We recommend using the player's default fallback strategy. However, if you want to specify a fixed stream URL for fallback, use this parameter. |
traceId | String | Your unique user identifier. Pass this value to public instrumentation points to track log reporting. By default, the Web Player SDK enables log reporting. Passing traceId helps identify users. If omitted, the Web Player SDK generates and stores a UUID in the browser cache. Note Supported in Web Player SDK version 2.10.0 and later. |
textTracks | Array | Configure external WebVTT captions. Example: Field descriptions:
Note
|
ratio | Number | Set the player to scale at a fixed aspect ratio. For example, given a video aspect ratio of 16:9, set the player parameters to |
extLanguageTexts | Object | The Web Player SDK includes built-in Chinese and English UI text. Use this property to customize text for specific UI elements. For example, to change the display of HD from high definition to 1080p: |
speedLevels | Array | Customize the playback speed list. Each object contains a key (speed value) and text (UI label). If omitted, the default list is used. Example: |
logo | Array | Configure custom logo images. Example: Field descriptions:
|
license | Object | To use value-added features such as Playback Quality Monitoring (Legacy), Single-point Troubleshooting, or H.265/H.266 Video Playback, first submit the Web Player SDK Value-added Services Application Form to obtain a license. Then integrate the license as follows: |
mute | Boolean | Enable muted playback. Configure this parameter to enable muted autoplay when browsers block autoplay. For details, see Advanced Features. |
clickPause | Boolean | Click the video area to pause or resume playback.
Default: true on desktop, false on mobile. Do not use with dbClickSkip to avoid interaction conflicts. |
disablePip | Boolean | Hide the browser's native Picture-in-Picture (PiP) button. Note
|
env | String | By default, player telemetry data uploads to the China data center. If you have compliance requirements for data outside China, set env: 'SEA' to upload data to the Singapore data center. |
watchStartTime | Number | Use alone to set the start time for playback. Use with watchEndTime to enable time-range playback. Users can only play and seek within the specified time range. Unit: seconds |
watchEndTime | Number | Use with watchStartTime to enable time-range playback. Users can only play and seek within the specified time range. If this value is less than watchStartTime, watchStartTime is ignored. Unit: seconds |
start | Number | Use with end to extract a segment from the video. For example, if the original video is 60 seconds long and you set start: 10 and end: 30, the player displays a 20-second video starting from the 10th second of the original video. |
end | Number | Use with start to extract a segment from the video. For example, if the original video is 60 seconds long and you set start: 10 and end: 30, the player displays a 20-second video starting from the 10th second of the original video. |
dbClickFullscreen | Boolean | Enable double-click to enter full screen. Enabled by default on desktop. |
longPressFastForward | Boolean | Enable long-press fast forward (mobile only). Valid values:
|
dbClickSkip | Boolean | Double-click left side to rewind, double-click right side to fast forward (mobile only). Valid values:
Do not use with clickPause to avoid interaction conflicts. |
enableMockFullscreen | Boolean | Enable CSS-based pseudo-fullscreen. By default, the player calls the browser's fullscreen API. On iOS and some Android browsers, the system player takes over full screen, causing UI issues. Enable this parameter to avoid takeover. Default: false. |
watermark | Object | Configure dynamic watermarks. Example: Field descriptions:
|
memoryPlay | Object | To enable resume playback, add the Field descriptions:
|
menuMode | String | Set where to display the playback speed, definition, caption, and audio track controls. Valid values:
|
Methods
You can call these methods after the ready event occurs or in the ready callback when creating the player. Examples:
// Method 1:
var player = new Aliplayer({}, function (player) {
player.play();
});
// Method 2:
var player = new Aliplayer({});
function handleReady(player) {
player.play();
};
player.on('ready', handleReady);Available methods for an Aliplayer instance:
play()
Start playback.
Function Definition
() => Playerpause()
Pause playback.
(showPlayButton?: boolean) => PlayerParameters
Name | Type | Required | Description |
showPlayButton | Boolean | No | Show the play button. |
replay()
Restart playback.
Function Definition
() => Playerseek()
Jump to a specific time.
Function Definition
(time: number) => Player Parameters
Name | Type | Required | Description |
time | number | Yes | Time to jump to. Unit: seconds. |
dispose()
Destroy the player.
Function Definition
() => voidgetCurrentTime()
Obtain the current playback time. The unit is seconds.
Function Definition
() => numbergetDuration()
Obtain the total video duration. The unit is seconds. You can call this method after the video loads or after the play event.
Function Definition
() => numbergetVolume()
Obtain the current volume. It returns a real number between 0 and 1. Not supported on iOS and some Android devices.
Function Definition
() => number | undefinedsetVolume()
Set the volume.
Function Definition
(volume: number) => voidParameters
Name | Type | Required | Description |
volume | number | Yes | Volume as a real number between 0 and 1. Not supported on iOS and some Android devices. |
mute()
Mute playback.
Function Definition
(quiet?: boolean) => PlayerParameters
Name | Type | Required | Description |
quiet | boolean | No | Hide the mute/unmute status text in the bottom-left corner. |
unMute()
Unmute playback.
Function Definition
(quiet?: boolean) => PlayerParameters
Name | Type | Required | Description |
quiet | boolean | No | Whether to hide the text prompt in the bottom-left corner when you unmute. |
getPlayTime()
Obtain the actual playback time (excluding paused time). For variable-speed playback, this returns the actual elapsed time. The unit is seconds.
Function Definition
() => numberloadByUrl()
Switch to another video. It supports switching only between videos of the same format, such as MP4, HLS, or FLV. To switch between different formats, you must destroy the player and create a new instance.
Function definition
(url: string, seconds?: number, autoPlay?: boolean) => voidParameters
Name | Type | Required | Description |
url | string | Yes | The URL of the video to switch to. |
seconds | number | No | Playback start time after switching. |
autoPlay | boolean | No | Start playback automatically after switching. |
replayByVidAndPlayAuth()
Switch to another VOD video. It supports switching only between videos of the same format.
Function Definition
(vid: string, playauth: string) => voidParameters
Name | Type | Required | Description |
vid | string | Yes | The video ID. |
playauth | string | Yes | The playback credential. |
replayByVidAndAuthInfo()
Switch to another MPS video. It supports switching only between videos of the same format.
Function Definition
(vid: string, accId: string, accSecret: string, stsToken: string, authInfo: string, domainRegion: string) => voidFor more information about parameter details, see MPS Playback.
replayByMediaAuth()
Switch to another Universal Media Service video. It supports switching only between videos of the same format.
Function definition
(mediaAuth: string) => voidParameters
Name | Type | Required | Description |
mediaAuth | string | Yes | The playback credential. |
getBuildInComponent()
Obtain a built-in UI component (such as a full-screen button or progress bar).
Function Definition
(name: string) => BuildInComponent;Parameters
Name | Type | Required | Description |
name | string | Yes | The built-in component name (e.g., fullScreenButton). See Configure the skinLayout Property for a list of component names. Each component supports hide and show methods. |
setPlayerSize()
Set the player size.
Function definition
(width: string, height: string) => voidParameters
Name | Type | Required | Description |
width | string | Yes | Set the player size. Valid values:
|
height | string | Yes |
setSpeed()
Manually set playback speed. This may not work on mobile devices (such as WeChat on Android). Speed controls are enabled by default.
Function Definition
(speed: number) => voidParameters
Name | Parameter type | Required | Description |
speed | number | Yes | Supports playback speeds from 0.5× to 2×. |
To disable speed controls:
You cannot disable or customize speed controls individually. You must disable them globally.
To disable speed controls via CSS override:
.prism-setting-speed { display: none !important; }
setTraceId()
Pass in common instrumentation for tracking logs.
Function definition
(traceId: string) => voidParameters
Name | Type | Required | Description |
traceId | string | Yes | A unique identifier. |
Supported in Web Player SDK version 2.10.0 and later.
setSanpshotProperties()
Configure screenshot settings.
Function Definition
(width: number, height: number, rate: number) => voidParameters
Name | Type | Required | Description |
width | number | Yes | Width and height units: pixels. Screenshot quality range: 0–1 (default: 1). For more details, see Video Screenshots. |
height | number | Yes | |
rate | number | Yes |
fullscreenService.requestFullScreen()
Enter full screen.
Function Definition
() => PlayerfullscreenService.cancelFullScreen()
Exit full screen. Not supported on iOS.
Function definition
() => PlayerfullscreenService.getIsFullScreen()
Obtain the full-screen state.
Function Definition
() => booleangetStatus()
Obtain the player state. It returns a string. Such as:
init: Initializing.
ready: Ready.
loading: Loading.
play: Playing.
pause: Paused.
playing: Playing.
waiting: Buffering.
error: Error.
ended: Ended.
Function Definition
() => stringliveShiftSerivce.setLiveTimeRange()
Set the start and end time for live streaming. Use this to enable time shifting.
Function Definition
(start: string, end: string) => voidParameters
Name | Type | Required | Description |
start | string | Yes | Start time for live streaming. |
end | string | Yes | End time for live streaming. |
Example
player.liveShiftSerivce.setLiveTimeRange('2025/03/21 12:43:00', '2025/03/21 23:31:00')setRotate()
Set the player rotation angle.
Function Definition
(rotate: number) => voidParameters
Name | Type | Required | Description |
rotate | number | Yes | Positive values rotate clockwise. Negative values rotate counterclockwise. Example: setRotate(90). For more information, see Set Display Mode. |
getRotate()
Obtain the player rotation angle.
Function Definition
() => numberFor more information, see Set Display Mode.
setImage()
Apply mirroring.
Function Definition
(type: string) => voidParameters
Name | Type | Required | Description |
type | string | Yes | Valid values:
Example: setImage('horizon'). For more information, see Set Display Mode. |
setCover()
Set the cover image.
Function Definition
(coverUrl: string) => voidParameters
Name | Type | Required | Description |
coverUrl | string | Yes | Thumbnail URL. |
setProgressMarkers()
Set progress markers.
Function definition
(markers: Array<{ time: number, text: string }>) => voidParameters
Name | Type | Required | Description |
markers | Array<markers> | Yes | markers: Array of marker objects (required). marker.time: Time of the marker (required). marker.text: Text label for the marker (required). See parameter progressMarkers for details. |
setPreviewTime()
Set preview duration.
Function Definition
(time: number) => voidParameters
Name | Type | Required | Description |
time | number | Yes | Unit: seconds. For more information, see Preview. |
getPreviewTime()
Obtain preview duration.
Function definition
() => numberisPreview()
Check if preview mode is active.
Function Definition
() => booleangetCurrentPDT()
Obtain the current ProgramDateTime for HLS video streams.
Function Definition
() => number | undefinedsetTextTracks()
Set an array of WebVTT captions.
Function definition
(textTracks: Array<{ kind: string, label: string, src: string, srclang: string }>) => voidParameters
Name | Type | Required | Description |
textTracks | Array<object> | Yes | Example: Note Supported in Web Player SDK version 2.12.0 and later. |
setLogo()
Set custom logo images.
Function definition
(logoList: Array<{ width: number, position: string, origin: string, src: string }>) => voidParameters
Name | Type | Required | Description |
logoList | Array<object> | Yes | Example: For field descriptions, see property: logo. |
setWatchTime()
Update the current video's watchStartTime/watchEndTime dynamically.
Function definition
(start: number, end: number) => voidParameters
Name | Type | Required | Description |
start | string | Yes | Start time. |
end | string | Yes | End time. |
setNextWatchTime()
Set the next video's watchStartTime/watchEndTime. If you use loadByUrl or replayByVidAndPlayAuth to switch videos, and the next video has a different time range than the current one, you must call setNextWatchTime first.
Function definition
(start: number, end: number) => voidParameters
Name | Type | Required | Description |
start | string | Yes | Start time. |
end | string | Yes | End time. |
setStartEnd()
Update the current video's start/end dynamically.
Function Definition
(start: number, end: number) => voidParameters
Name | Type | Required | Description |
start | string | Yes | Start time. |
end | string | Yes | End time. |
setNextStartEnd()
Set the next video's start/end. If you use loadByUrl or replayByVidAndPlayAuth to switch videos, and the next video has a different segment range than the current one, you must call setNextStartEnd first.
Function Definition
(start: number, end: number) => voidParameters
Name | Type | Required | Description |
start | string | Yes | Start time. |
end | string | Yes | End time. |
takeSnapshot()
Capture a screenshot. The returned base64 string can be used directly as an img.src value. You can use setSnapshotProperties to configure screenshot quality and snapshotWatermark to add a watermark.
Note: Screenshot functionality may not work on some mobile browsers where the video tag is hijacked (such as UC Browser or QQ Browser).
Function Definition
() => { time: number, base64: string, binary: string, error: Error | null }Return value
Name | Type | Description |
time | string | Screenshot time. |
base64 | string | Base64-encoded screenshot content. |
binary | string | Binary string representation of the screenshot content. |
error | Error | Details of any screenshot error. |
showControlBar()
Show the control bar.
Function Definition
() => voidhideControlBar()
Hide the control bar.
Function Definition
() => voidEvents
Player Events
Name | Description |
ready | The player UI finishes rendering. Trigger UI initialization logic after this event to avoid being overwritten by default initialization. Note You can call player methods only after this event occurs. |
play | Fires when playback resumes from pause. |
pause | Fires when playback pauses. |
canplay | Fires when audio or video can begin playing. This event may fire multiple times. HTML5 players only. |
playing | Fires repeatedly during playback. |
ended | Fires when the current video finishes playing. |
liveStreamStop | Fires when a live stream stops. For HLS live streams, this fires after five failed retries. Notify the application layer that the stream has stopped or needs reloading. Note If an HLS live stream fails or disconnects, the player automatically retries five times. Do not implement additional retry logic at the application layer. |
onM3u8Retry | Fires once each time the player retries after an HLS live stream interruption. |
hideBar | Fires when the control bar hides automatically. |
showBar | The control bar automatically displays (event)s. |
waiting | Fires when buffering data. |
timeupdate | Fires when playback position changes. Call getCurrentTime() to get the current playback time. |
snapshoted | Fires when a screenshot completes. |
requestFullScreen | Fires when entering full screen. |
cancelFullScreen | Fires when exiting full screen. Does not fire on iOS. |
error | Fires when an error occurs. |
startSeek | The parameter returns the creation time of the drag point at the start of a drag operation. |
completeSeek | When you complete the drag operation, the parameters indicate the timestamp of the drag point. |
resolutionChange | Fires when the live stream source changes resolution. |
seiFrame | Fires when receiving SEI messages over HLS or FLV. |
rtsFallback | Fires when RTS falls back. The |
settingSelected | Fires when a setting (e.g., playback speed, definition, caption) is selected. Note Because the open-source speed plugin does not sync with the player, using it requires custom code and recompilation. Define your own event listener. To use the player's |
rtsTraceId | This event is triggered when RTS stream pulling is successful, and you can subscribe to it to obtain the RTS TraceId. In the log output, the `traceId` field of the |
autoplay | Fires when autoplay succeeds or fails. The callback parameter |
mutedAutoplay | Fires when muted autoplay succeeds and |
videoUnavailable | Fires when video playback fails due to unsupported encoding, causing a black screen. For example, playing H.265 video in a browser that does not support H.265 results in a black screen with audio only. |
Event Subscription
You can subscribe to events using the player instance's on method. For example:
function handleReady() {}; player.on('ready', handleReady); // Some events fire frequently. Use player.one to listen once. player.one('canplay', () => {});You can unsubscribe from events using the player instance's off method. For example:
player.off('ready',handleReady);