Skip to content

API Docs

This page is the compact reference for the current h265web.js PRO browser SDK.

Path Rules

The current SDK accepts these path styles for both SDK resources and media URLs:

  • Full URL: https://example.com/output/h265web_wasm.js
  • Site-absolute path: /output/h265web_wasm.js
  • Relative path: ./output/h265web_wasm.js

If you want to resolve the four SDK resource files from one shared base path, use base_url.

Build Flow

Recommended public usage:

  1. Create the player object.
  2. Bind the callbacks you need.
  3. Call build(config).
  4. Call load_media(mediaUrl).
js
const ylplayer = H265webjsPlayer();

ylplayer.on_ready_show_done_callback = function () {
  console.log('ready');
};

ylplayer.video_probe_callback = function (mediaInfo) {
  console.log('probe', mediaInfo);
};

ylplayer.build({
  player_id: 'canvas111',
  base_url: './output/',
  wasm_js_uri: 'h265web_wasm.js',
  wasm_wasm_uri: 'h265web_wasm.wasm',
  ext_src_js_uri: 'extjs.js',
  ext_wasm_js_uri: 'extwasm.js',
  width: '100%',
  height: 480,
  auto_play: true,
  ignore_audio: false
});

ylplayer.load_media('./resource/demo.mp4');

build(config)

Config Fields

ParameterTypeRequiredDescription
player_idstringYesPlayer container element id
wasm_js_uristringYesResource path for h265web_wasm.js
wasm_wasm_uristringYesResource path for h265web_wasm.wasm
ext_src_js_uristringNoResource path for extjs.js
ext_wasm_js_uristringNoResource path for extwasm.js
base_urlstringNoOptional shared base path for SDK resource resolution
widthnumber | stringNoPlayer width
heightnumber | stringNoPlayer height
colorstringNoPlayer background color
auto_playbooleanNoAuto play after media is ready
readframe_multi_timesnumberNoDemux feed scale
corestringNoExplicit core: mse_hevc, wasm_hevc, webcodec_hevc
ignore_audiobooleanNoIgnore audio track
media_uristringNoOptional media URL. Public examples still recommend build() followed by load_media()

Core Methods

release()

js
ylplayer.release();

load_media(mediaUrl)

js
ylplayer.load_media('./resource/hevc_test_moov_set_head_16s.mp4');

change_media(mediaUrl)

js
ylplayer.change_media('/resource/another-demo.mp4');

play()

js
ylplayer.play();

pause()

js
ylplayer.pause();

seek(seconds)

js
ylplayer.seek(10);

set_playback_rate(rate)

js
ylplayer.set_playback_rate(2.0);

set_voice(volume)

js
ylplayer.set_voice(0.5);

set_mute()

js
ylplayer.set_mute();

screenshot(imgId)

html
<img id="screenshot" style="width:400px;height:340px;background:#e9e9e9;" />
js
ylplayer.screenshot('screenshot');

next_frame()

js
ylplayer.next_frame();

resize(width, height)

js
ylplayer.resize(640, 480);

fullScreen()

js
ylplayer.fullScreen();

closeFullScreen()

js
ylplayer.closeFullScreen();

Required Callbacks

on_ready_show_done_callback

js
ylplayer.on_ready_show_done_callback = function () {
  console.log('on_ready_show_done_callback');
};

video_probe_callback(mediaInfo)

js
ylplayer.video_probe_callback = function (mediaInfo) {
  console.log('video_probe_callback', mediaInfo);
};

Playback And Seek Callbacks

on_play_time(pts)

js
ylplayer.on_play_time = function (pts) {
  console.log('on_play_time', pts);
};

on_play_finished()

js
ylplayer.on_play_finished = function () {
  console.log('on_play_finished');
};

on_seek_start_callback(seekTarget)

js
ylplayer.on_seek_start_callback = function (seekTarget) {
  console.log('on_seek_start_callback', seekTarget);
};

on_seek_done_callback(seekTarget)

js
ylplayer.on_seek_done_callback = function (seekTarget) {
  console.log('on_seek_done_callback', seekTarget);
};

Cache Callbacks

on_cache_process_callback(timestamp)

js
ylplayer.on_cache_process_callback = function (timestamp) {
  console.log('on_cache_process_callback', timestamp);
};

on_load_caching_callback()

js
ylplayer.on_load_caching_callback = function () {
  console.log('on_load_caching_callback');
};

on_finish_cache_callback(data)

js
ylplayer.on_finish_cache_callback = function (data) {
  console.log('on_finish_cache_callback', data);
};