Class: ZegoMediaPlayer

ZegoMediaPlayer()

ZegoMediaPlayer

Constructor

new ZegoMediaPlayer()

Source:

Methods

enableAux(enable)

Whether to mix the player's sound into the stream being published.
Parameters:
Name Type Description
enable boolean Aux audio flag. The default is false.
Source:

enablePublishVideo(enable, channel)

Whether to mix the player's video into the stream being published.
Parameters:
Name Type Description
enable boolean enable publish video
channel number channel
Source:

enableRepeat(enable)

Whether to repeat playback.
Parameters:
Name Type Description
enable boolean repeat playback flag. The default is false.
Source:

getAudioTrackCount() → {number}

Get the number of audio tracks of the playback file.
Source:
Returns:
- Number of audio tracks
Type
number

getCurrentProgress() → {number}

Get current playing progress. You should load resource before invoking this function, otherwise the return value is 0
Source:
Returns:
- current progress
Type
number

getCurrentState() → {ZegoMediaPlayerState}

Get the current playback status.
Source:
Returns:
- current state
Type
ZegoMediaPlayerState

getPlayVolume() → {number}

Gets the current local playback volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.
Source:
Returns:
- current volume
Type
number

getPublishVolume() → {number}

Gets the current publish volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.
Source:
Returns:
- current volume
Type
number

getTotalDuration() → {number}

Get the total progress of your media resources. You should load resource before invoking this function, otherwise the return value is 0
Source:
Returns:
- Unit is millisecond
Type
number

loadResource(path) → {Promise.<number>}

Load media resource. Yon can pass the absolute path of the local resource or the URL of the network resource
Parameters:
Name Type Description
path string the absolute path of the local resource or the URL of the network resource
Source:
Returns:
- load resource result
Type
Promise.<number>

muteLocal(mute)

Whether to play locally silently. If [enableAux] switch is turned on, there is still sound in the publishing stream. The default is false.
Parameters:
Name Type Description
mute boolean Mute local audio flag, The default is false.
Source:

pause()

Pause playing.
Source:

resume()

Resume playing.
Source:

seekTo(millisecond) → {Promise.<number>}

Set the specified playback progress. Unit is millisecond
Parameters:
Name Type Description
millisecond number Point in time of specified playback progress
Source:
Returns:
- seek result
Type
Promise.<number>

setAudioTrackIndex(index)

Set the audio track of the playback file.
Parameters:
Name Type Description
index number Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.
Source:

setPlayerView(view)

Set the view of the player playing video.
Parameters:
Name Type Description
view ZegoView Video rendered view object
Source:

setPlayVolume(volume)

Set mediaplayer local playback volume.
Parameters:
Name Type Description
volume number The range is 0 ~ 200. The default is 60.
Source:

setProgressInterval(millisecond)

Set playback progress callback interval. This function can control the callback frequency of [onMediaPlayerPlayingProgress]. When the callback interval is set to 0, the callback is stopped. The default callback interval is 1s This callback are not returned exactly at the set callback interval, but rather at the frequency at which the audio or video frames are processed to determine whether the callback is needed to call
Parameters:
Name Type Description
millisecond number Interval of playback progress callback in milliseconds
Source:

setPublishVolume(volume)

Set mediaplayer publish volume.
Parameters:
Name Type Description
volume number The range is 0 ~ 200. The default is 60.
Source:

setVoiceChangerParam(audioChannel, param)

Setting up the specific voice changer parameters.
Parameters:
Name Type Description
audioChannel ZegoMediaPlayerAudioChannel The audio channel to be voice changed
param ZegoVoiceChangerParam Voice changer parameters
Source:

setVolume(volume)

Set mediaplayer volume. Both the local play volume and the publish volume are set.
Parameters:
Name Type Description
volume number The range is 0 ~ 200. The default is 60.
Source:

start()

Start playing. You need to load resources before playing
Source:

stop()

Stop playing.
Source:

takeSnapshot() → {Promise.<number, string>}

Take a screenshot of the current playing screen of the media player. Only in the case of calling `setPlayerCanvas` to set the display controls and the playback state, can the screenshot be taken normally
Source:
Returns:
- snapshot error code(errorCode) and base64 string of the image in jpg format(image)
Type
Promise.<number, string>

Events

onMediaPlayerNetworkEvent

The callback triggered when the network status of the media player changes.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
networkEvent ZegoMediaPlayerNetworkEvent Network status event
Source:

onMediaPlayerPlayingProgress

The callback to report the current playback progress of the media player.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
millisecond number Progress in milliseconds
Source:

onMediaPlayerStateUpdate

The callback triggered when the state of the media player changes.
Properties:
Name Type Description
result object param object
Properties
Name Type Description
state ZegoMediaPlayerState Media player status
errorCode number Error code, please refer to the error codes document https://doc-en.zego.im/en/5548.html for details.
Source: