Skip to content

Media Playback API

VOD (Video on Demand) playback and background music during class.

API Reference

getMediaPlayState()

Get the current VOD playback state.

与 state.vodCurrentTime$(有 200ms 节流)不同,此方法调用时实时计算 currentTime, Unlike state.vodCurrentTime$ (throttled at 200ms), this method calculates currentTime in real-time, returning the exact pause position instead of a stale signal value when VOD is paused.

Returns: object


pauseMusic()

Pause background music (teacher side). state.musicPlayStatus$ becomes 'paused'.

Returns: Promise<TResult<void>>


pauseVod()

Pause VOD playback (teacher side).

After pausing, all students sync-pause; state.vodPlayStatus$ becomes 'paused'.

Returns: Promise<TResult<void>>


resumeMusic()

Resume background music (teacher side).

Returns: Promise<TResult<void>>


resumeVod()

Resume VOD playback (teacher side).

Returns: Promise<TResult<void>>


seekMusic()

Seek background music (teacher side; all clients sync).

ParameterTypeDescription
timenumberPlayback time in seconds

Returns: Promise<TResult<void>>


seekVod()

Seek VOD playback to a specific time (teacher side).

After seeking, all students sync to the same time point.

ParameterTypeDescription
timenumberSeek time in seconds

Returns: Promise<TResult<void>>

Example:

ts
// 跳到第 30 秒 / Seek to 30s
await classroom.seekVod(30);

setMusicVolume()

Set local music volume (local only, no signaling broadcast).

Students can independently adjust their own volume without affecting others.

ParameterTypeDescription
volumenumberVolume level (0~100)

Returns: Promise<TResult<void>>

Example:

ts
await classroom.setMusicVolume(50); // 50% 音量 / 50% volume

startMusic()

Start background music playback (teacher side).

ParameterTypeDescription
paramMusicPlayParamMusic playback parameters

Returns: Promise<TResult<void>>

Example:

typescript
const result = await classroom.startMusic({
  url: 'https://example.com/bgm.mp3',
  title: 'Background Music',
});
if (!result.ok) { console.error('Music start failed:', result.message); }

startVod()

Start VOD video playback (teacher side).

ParameterTypeDescription
paramVodPlayParamVOD parameters (videoId or url, pick one)

Returns: Promise<TResult<void>>

Example:

typescript
const result = await classroom.startVod({ url: 'https://example.com/video.mp4' });
if (!result.ok) { console.error('VOD start failed:', result.message); }

stopMusic()

Stop background music playback (teacher side; all clients sync-stop).

Returns: Promise<TResult<void>>


stopVod()

Stop VOD playback (teacher side). All students close the VOD player.

Returns: Promise<TResult<void>>