Property and Interface Description
Player Properties
| Name | Type | Default | Description | PC Compatibility | Mobile Compatibility |
|---|---|---|---|---|---|
| wrap | String / HTMLElement | / | DOM element to load the player, supports passing an element or element selector (loaded only on the first element). | ✔ | ✔ |
| vid | String | / | Unique video ID on the cloud video platform. | ✔ | ✔ |
| width | Number / String | 100% | Player width, supports pixel values and percentages, e.g., 200 or 100%. | ✔ | ✔ |
| height | Number / String | / | Player height, supports pixel values, percentages, and auto-adaptation, e.g., 100, 40%. When the value is auto or empty, the height is automatically calculated based on the video aspect ratio (only effective on PC). |
✔ | ✔ |
| autoplay | Boolean | / | Whether to autoplay. Note: Most browsers currently restrict autoplay; this parameter may be ineffective. |
✔ | ✔ |
| loop | Boolean | false | Whether to enable loop playback. | ✔ | ✔ |
| forceH5 | Boolean | / | Whether to use the H5 player by default when using multi-terminal code. Note: Flash will still be used if the browser does not support H5. |
✔ | ✘ |
| flash | Boolean | false | Whether to use the Flash player by default. | ✔ | ✘ |
| hideSwitchPlayer | Boolean | false | Whether to hide the H5 and Flash player switch button. | ✔ | ✘ |
| playsafe | String/Function | / | Authorization credential required for playing encrypted videos. See: Play Encrypted Video. Function usage: playsafe: function(vid, next) { $.ajax({ url: 'token API', type: "POST", data: obj, }).done(function(res) { next(res.data.token); }); }, |
✔ | ✔ |
| playsafeUrl | String | / | URL to obtain the credential for playing encrypted videos. Use either this or the playsafe parameter. |
✔ | ✔ |
| disposable | Boolean | false | If the disposable parameter was passed when generating the playsafe token, the token is valid only once. Switching quality will cause playback failure. Set this parameter to true if the token request included disposable. Note: Requires playsafe <Function> or playsafeUrl |
✔ | ✘ |
| sign | String | / | Signature required for playing encrypted videos on mobile. See: Play Encrypted Video. | ✘ | ✔ |
| ts | Number | / | Timestamp required for playing encrypted videos on mobile. | ✘ | ✔ |
| viewerInfo | Object | / | Custom viewer information. When set, the player's viewing behavior logs will include viewer information. See: Viewer Info Setting and Statistics. | ✔ | ✔ |
| video_align | String | / | Alignment of the video within the player. Default is center. Values: {top, bottom, left, right}. | ✔ | ✔ |
| loading_bg_img | String | / | URL of the video poster image. | ✔ | ✔ |
| cover_display | String | scaleToFill | Display mode of the cover image: scaleToFill (stretch), scaleAspectFit (fit), scaleAspectFill (fill). | ✔ | ✔ |
| cover_opacity | Number | 70 | Opacity of the cover image overlay, range: [0,100]. | ✔ | ✘ |
| showHd | Boolean | true | Whether to show the quality selection button. | ✔ | ✔ |
| show_rate | Number | / | Maximum selectable quality, values: {1,2}. 1 shows only smooth, 2 allows smooth and HD. | ✔ | ✔ |
| showAuto | Boolean | true | Whether to show the "Auto" option in quality selection. | ✔ | ✘ |
| df | Number | - | Default playback quality, values: {0,1,2,3}, corresponding to Auto, Smooth, HD, Super HD. | ✔ | ✔ |
| speed | Boolean/Array | true | When boolean, indicates whether to show the speed switch button. When an array, represents the selectable speeds. No limit on the number of speeds. Recommended range (0,3]. PC default: [2, 1.5, 1.2, 0.5], Mobile default: [1, 1.5, 2]. | ✔ | ✔ |
| showLine | Boolean | true | Whether to show the line selection button. | ✔ | ✔ |
| volume | Number | 0.75 | Default volume, range: (0,1). The player remembers the last volume. | ✔ | ✔ |
| allowFullscreen | Boolean | true | Whether to allow fullscreen playback. When false, hides the fullscreen button (fullscreen API still available). Note: Not supported on mobile v1. |
✔ | ✔ |
| fullscreenProxy | Boolean | false | Whether to use fullscreen proxy. When true, clicking fullscreen does not call the fullscreen API but triggers the window.onFullscreenProxy(vid, toFullscreen) event, allowing custom fullscreen handling. | ✔ | ✘ |
| full_page_screen | Boolean | false | Whether to show the web page fullscreen button. Requires configuring the window.onFullPageScreen event callback for handling. | ✔ | ✘ |
| pictureInPicture | Boolean | false | Whether to show the picture-in-picture button in the control bar. Note: Only effective for non-encrypted videos. |
✔ | ✘ |
| screenshot | Boolean | false | Whether to show the video screenshot button. | ✔ | ✘ |
| skinLocation | Number | 1 | Player control bar display position: 0 hidden, 1 inside video area, 2 outside video area. Note: Mobile v1 uses ban_ui: true instead of skinLocation: 0 |
✔ | ✔ |
| hideRepeat | Boolean | false | Whether to hide the replay button after playback ends. | ✔ | ✔ |
| ban_seek | String | off | Whether to disable progress bar dragging, values: {on, off}. Note: Behavior may vary across Android browsers; this parameter may not work. |
✔ | ✔ |
| ban_seek_by_limit_time | String | off | Whether to disable dragging the progress bar to unplayed positions, values: {on, off}. When on, dragging is only allowed within the already played range (forward). | ✔ | ✔ |
| cacheLimitTime | Boolean | false | Whether to cache the maximum played duration. Used with ban_seek_by_limit_time. When set, the draggable area for the same video is the historical maximum watch time. Note: Not supported on mobile v1. |
✔ | ✔ |
| banSeekDeviation | Number | / | Sets the maximum seek time when ban_seek is set, in seconds. | ✔ | ✔ |
| ban_preview_video | String | off | Whether to disable the thumbnail preview when hovering over the progress bar, values: {on, off}. When on, no preview thumbnail is shown. | ✔ | ✘ |
| keyboardSeekTime | Number | 15000 | Time to seek forward/backward per keyboard arrow key press, in milliseconds. | ✔ | ✘ |
| watchStartTime | Number | / | Playback start time, indicating the second from which the video starts playing. Must be less than the video duration. | ✔ | ✔ |
| watchEndTime | Number | / | Playback end time, indicating the second at which the video stops playing. When set, progress bar dragging is limited to the range between start and end time. Must be greater than watchStartTime and less than video duration. If less than watchStartTime, watchStartTime is invalid. | ✔ | ✔ |
| start | Number | / | Trims a portion of the video as an independent video. E.g., if the original video is 60 seconds, setting start=20 makes the video appear as 40 seconds, starting from the 20th second. Usually used with the end parameter (sub-video feature). | ✔ | ✔ |
| end | Number | / | Trims a portion of the video as an independent video. E.g., setting start=20, end=50 makes the video appear as 30 seconds, playing from the 20th to the 50th second. | ✔ | ✔ |
| preview | Boolean | false | Whether to use preview mode. Playback stops after the preview duration, which can be configured in the admin console. | ✔ | ✔ |
| previewDuration | Number | / | Preview duration, in seconds. Optional. If not set and preview is enabled, defaults to the admin console setting. Note: 1. For non-encrypted videos, the system displays the preview for the duration set by this parameter. 2. For encrypted videos, the actual preview duration is the shorter of the actual video encoding length and this parameter. It is recommended not to exceed the admin console setting to avoid issues. |
✔ | ✔ |
| history_video_duration | Number | 5 | Default duration (in minutes) after which the resume playback feature is enabled. The resume time point is not recorded during the first and last 10 seconds of playback. | ✔ | ✔ |
| ban_history_time | String | off | Whether to disable the resume playback feature, values: {on, off}. on: disable, off: enable. | ✔ | ✔ |
| historyTimeType | String | local | Values: "local" or "remote". Storage method for resume playback records. "local" stores in localStorage, "remote" stores on the polyv server. Note: When configured as "remote", subsequent records are not stored locally, and if both exist, the remote value is read first. | ✔ | ✔ |
| preloadDataSize | Number | 15000 | Preloaded data amount, loads slice count based on actual video duration and quality, range: [500,60000], in KB. Note: Only effective for HLS videos (encrypted) on PC. |
✔ | ✘ |
| preloadDurationLength | Number | / | Maximum video preload duration, in seconds. | ✔ | ✘ |
| url | String | / | Third-party video resource URL. Cannot be set simultaneously with vid. | ✔ | ✔ |
| logo | Object | / | Player logo configuration parameters. See: Player Logo. | ✔ | ✔ |
| teaser_show | Number | / | Whether to play the teaser: 0 no, 1 yes. The teaser can be set in the admin console. | ✔ | ✔ |
| teaser_time | Number | / | Teaser display duration. | ✔ | ✔ |
| teaser_url | String | / | Teaser URL. Video only supports mp4 format. | ✔ | ✔ |
| teaserSkip | Boolean | false | Whether to show the skip teaser button. Note: Due to video layering, this parameter may not work on some mobile browsers. |
✔ | ✔ |
| tail_show | Number | / | Whether to play the tail: 0 no, 1 yes. The tail can be set in the admin console. | ✔ | ✔ |
| tail_time | Number | / | Tail display duration. | ✔ | ✔ |
| tail_url | String | / | Tail URL. Video only supports mp4 format. | ✔ | ✔ |
| tailSkip | Boolean | / | Whether to show the skip tail button. | ✔ | ✔ |
| ban_ad | Boolean | false | Whether to disable ad playback. | ✔ | ✔ |
| ban_ad_time | Boolean | false | Whether to hide the ad countdown. | ✔ | ✔ |
| adMatter | Array | / | Ad configuration parameters. See: Ad Settings. | ✔ | ✔ |
| adSkip | Boolean | false | Whether to show the skip ad button. | ✔ | ✔ |
| rightMenu | Array | / | Right-click menu configuration. Example: rightMenu: [{rightName: 'Display Name', rightUrl: 'Click URL', callback: function(){console.log('hi')}},{rightName: 'Menu 2', rightUrl: '', callback: function(){console.log('hello')}}] | ✔ | ✘ |
| lang | String | zh_CN | Player language, supports Chinese and English, values: {zh_CN, en}. | ✔ | ✔ |
| priorityMode | String | video | Default mode: video or audio, values: {video, audio}. Note: Only videos with an additional audio track can switch between video and audio modes. |
✔ | ✔ |
| videoMode | Boolean | true | When false, enables audio mode. Note: Only effective on PC. Audio mode is enabled even without an additional audio track. Note: Not supported on mobile v1. |
✔ | ✔ |
| audioMode | Boolean | true | Whether to enable audio mode (only effective if the source video supports audio). | ✔ | ✔ |
| is_interaction | String | on | Whether to display quiz questions set in the admin console during video playback. Values: {on, off}. See: Quiz Popup Feature. | ✔ | ✘ |
| ban_record_interaction_right_answer | String | off | Whether to disable the player from caching quiz submission records. Values: {on, off}. When set to "on", the quiz must be retaken each time the video is played. | ✔ | ✘ |
| title_of_right_answer_explain | String | / | Prompt text when a quiz answer is correct. | ✔ | ✘ |
| title_of_wrong_answer_explain | String | / | Prompt text when a quiz answer is incorrect. | ✔ | ✘ |
| pptEnable | Boolean | false | Whether to enable the courseware three-screen playback mode. See: Courseware Three-Screen Playback. | ✔ | ✘ |
| mainScreen | String | ppt | Main screen in three-screen playback mode, values: {ppt, video}. | ✔ | ✘ |
| subWidth | Number | 355 | Default width of the secondary screen in three-screen playback mode. | ✔ | ✘ |
| subHeight | Number | 200 | Default height of the secondary screen in three-screen playback mode. | ✔ | ✘ |
| pptVisible | Boolean | true | Whether to display the PPT on initialization in three-screen playback mode. | ✔ | ✘ |
| srtBackground | String | / | Subtitle background color, hexadecimal. E.g., '#333333'. | ✔ | ✘ |
| srt_caption_txt_size | Number | 20 | Subtitle font size, range: [20,40], in px. | ✔ | ✘ |
| srt_caption_txt_height | Number | 20 | Subtitle distance from the bottom of the player, in px. | ✔ | ✘ |
| srt_caption_base_width | Number | 1280 | Subtitle font size changes with player size. This value is the base width of the player. | ✔ | ✘ |
| srt_caption_base_height | Number | 720 | Subtitle font size changes with player size. This value is the base height of the player. | ✔ | ✘ |
| showSrt | Boolean | true | Whether to enable subtitle display. | ✔ | ✔ |
| defaultSubtitle | String | - | Default subtitle parameter, must match the string set in the admin console (subtitle file name). | ✔ | ✘ |
| useSingleSubtitleStyle | Boolean | true | Whether the single subtitle style responds to admin console settings. | ✔ | ✘ |
| code | String | / | Custom code value for the marquee. See: Authorized Playback and Video Marquee. | ✔ | ✔ |
| marqueeCheck | Boolean | / |
Custom Tracking Settings
const videoKeyframes = [{
// 打点出现时间
keytime: 80,
// 打点提示内容
keycontent: 'test111',
// 打点跳转按钮文案,可选
btnDesc: 'text',
// 打点跳转按钮跳转链接,可选
btnHref: 'https://www.example.com/'
}]
Player Interface
The API needs to be called after the player initialization is complete, for example:
player.on('s2j_onPlayerInitOver',function(e) {
player.j2s_seekVideo(100);
});
API List
| Name | Parameters & Type | Return Value & Type | Description
Player Events
| Name | Description | PC Compatibility | Mobile Compatibility |
|---|---|---|---|
| s2j_onPlayerInitOver | Triggered when the player initialization is complete. Player methods can only be called after this event. Returns the vid parameter. | ✔ | ✔ |
| s2j_onReadyPlay | Triggered when enough data has been loaded to start playing the video. Returns the vid parameter. | ✔ | ✘ |
| s2j_onPlayStart | Triggered when the video starts playing for the first time. Returns the vid parameter. | ✔ | ✔ |
| s2j_onVideoPlay | Triggered when the video starts playing for the first time or resumes from pause. Returns the vid parameter. | ✔ | ✔ |
| s2j_onVideoPause | Triggered when the video is paused. Returns the vid parameter. | ✔ | ✔ |
| s2j_onVideoSeek | Triggered when the video progress is dragged. Returns the start and end seek time points and the vid parameter. | ✔ | ✔ |
| s2j_onPlayOver | Triggered when the current video finishes playing. Returns the vid parameter. | ✔ | ✔ |
| s2j_volumeChange | Triggered when the audio volume changes. Returns the vid parameter and the changed volume. | ✔ | ✘ |
| s2j_onFullScreen | Triggered when the player enters fullscreen. Returns the vid parameter. Note: On mobile, only works in web fullscreen mode. |
✘ | ✔ |
| s2j_onNormalScreen | Triggered when the player exits fullscreen. Returns the vid parameter. Note: On mobile, only works in web fullscreen mode. |
✘ | ✔ |
| s2j_onPlayerError | Triggered when a playback error occurs. Returns the vid parameter. | ✔ | ✔ |
| HTML5Load | Triggered when switching from Flash to H5 player. | ✔ | ✘ |
| flashLoad | Triggered when switching from H5 player to Flash player on PC. | ✔ | ✘ |
| serverError | Triggered when a business logic error occurs, such as authorization verification failure or domain whitelist/blacklist validation failure. Returns the event name and error code. | ✔ | ✔ |
| onChangeMode | Triggered when the audio/video mode changes. Returns the vid parameter, the mode after switching, and the mode before switching. | ✔ | ✔ |
| onFullscreenProxy | When the fullscreenProxy parameter is set to true, clicking the fullscreen button does not call the fullscreen API but triggers the window.onFullscreenProxy(vid, toFullscreen) event. The caller handles fullscreen themselves, suitable for overlaying custom elements in fullscreen mode. |
✔ | ✘ |
| onFullPageScreen | When full_page_screen is set to true, clicking the web fullscreen button triggers the window.onFullPageScreen(vid, currentStatus) event. The caller handles web fullscreen themselves.window.onFullPageScreen = function (vid, currentStatus) {}) |
✔ | ✘ |
| adSkip | Returns the type of skipped ad, consistent with the set ad type. Triggered when an ad is skipped. Can be used to distinguish VIP users who can truly skip ads. |
✔ | ✘ |
| teaserSkip | Triggered when clicking to skip the teaser. | ✔ | ✘ |
| onTimeupdate | Triggered during video playback and seek. Returns the current playback progress in real-time (in seconds, with decimal points). | ✔ | ✘ |
| toggleClickPlay | Triggered when the user actively plays/pauses via the UI. Returns a Boolean indicating whether it is paused. | ✔ | ✔ |
Note: Due to historical reasons, the event return parameters of the three web-based players (Flash, PC H5, and Mobile H5) have not yet been aligned. The table above is based on the PC H5 player.
Subscribe via the player instance's on method:
function fn(params) {
console.log('播放器数据初始化完毕:',params);
}
player.on('s2j_onPlayerInitOver', fn);
Unsubscribe using the off method of the player instance:
player.off('s2j_onPlayerInitOver', fn);
