Package im.zego.zegoexpress.internal
Class ZegoMediaPlayerInternalImpl
- java.lang.Object
-
- im.zego.zegoexpress.ZegoMediaPlayer
-
- im.zego.zegoexpress.internal.ZegoMediaPlayerInternalImpl
-
public final class ZegoMediaPlayerInternalImpl extends ZegoMediaPlayer
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.concurrent.ConcurrentHashMap<ZegoMediaPlayer,im.zego.zegoexpress.internal.ZegoMediaPlayerInternalImpl.IdxAndHandler>
mediaplayerToIdxAndEventhandler
static android.os.Handler
mUIHandler
-
Constructor Summary
Constructors Constructor Description ZegoMediaPlayerInternalImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearView()
Clears the last frame of the playback control that remains on the control after playback ends.static ZegoMediaPlayer
createMediaPlayer()
static void
destroyAllMediaPlayer()
static void
destroyMediaPlayer(ZegoMediaPlayer mediaplayer)
void
enableAccurateSeek(boolean enable, ZegoAccurateSeekConfig config)
Enable accurate seek and set relevant attributes.void
enableAux(boolean enable)
Whether to mix the player's sound into the stream being published.void
enableFrequencySpectrumMonitor(boolean enable, int millisecond)
Whether to enable frequency spectrum monitoring.void
enableLiveAudioEffect(boolean enable, ZegoLiveAudioEffectMode mode)
Enable live audio effect.void
enableLocalCache(boolean enable, java.lang.String cacheDir)
Enable local caching of http/https network resources.void
enableRepeat(boolean enable)
Whether to repeat playback.void
enableSoundLevelMonitor(boolean enable, int millisecond)
Whether to enable sound level monitoring.void
enableViewMirror(boolean enable)
Enable the view mirror.void
enableVoiceChanger(ZegoMediaPlayerAudioChannel audioChannel, boolean enable, ZegoVoiceChangerParam param)
Enable voice changer, set up the specific voice changer parameters.int
getAudioTrackCount()
Get the number of audio tracks of the playback file.long
getCurrentProgress()
Get current playing progress.long
getCurrentRenderingProgress()
Get current rendering progress.ZegoMediaPlayerState
getCurrentState()
Get the current playback status.int
getIndex()
Get media player index.ZegoMediaPlayerMediaInfo
getMediaInfo()
Get meida information such as video resolution from media file.ZegoNetWorkResourceCache
getNetWorkResourceCache()
Get the playable duration and size of the cached data of the current network material cache queueZegoMediaPlayerStatisticsInfo
getPlaybackStatistics()
Get playback statistics.int
getPlayVolume()
Gets the current local playback volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.int
getPublishVolume()
Gets the current publish volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.long
getTotalDuration()
Get the total progress of your media resources.void
loadCopyrightedMusicResourceWithPosition(java.lang.String resourceId, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Load copyrighted music resource.void
loadResource(java.lang.String path, IZegoMediaPlayerLoadResourceCallback callback)
Load local or network media resource.void
loadResourceFromMediaData(byte[] mediaData, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Load binary audio resource.void
loadResourceWithConfig(ZegoMediaPlayerResource resource, IZegoMediaPlayerLoadResourceCallback callback)
Load local or network media resource with config.void
loadResourceWithPosition(java.lang.String path, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Load local or network media resource and specify the start position.void
muteLocal(boolean mute)
Whether to play locally silently.void
pause()
Pause playing.void
resume()
Resume playing.void
seekTo(long millisecond, IZegoMediaPlayerSeekToCallback callback)
Set the specified playback progress.void
setActiveAudioChannel(ZegoMediaPlayerAudioChannel audioChannel)
Set the playback channel.void
setAudioHandler(IZegoMediaPlayerAudioHandler handler)
Set audio data callback handler of the media player.void
setAudioTrackIndex(int index)
Set the audio track of the playback file.void
setAudioTrackMode(ZegoMediaPlayerAudioTrackMode mode)
Set the audio track mode of the player.void
setAudioTrackPublishIndex(int index)
Set the audio track for the media file to be publish.void
setBlockDataHandler(IZegoMediaPlayerBlockDataHandler handler, int blockSize)
Set the media resource block data callback handler of the media player.void
setEventHandler(IZegoMediaPlayerEventHandler handler)
Set event notification callback handler of the media player.void
setHttpHeader(java.util.HashMap<java.lang.String,java.lang.String> headers)
Set http headers.void
setNetWorkBufferThreshold(int threshold)
Use this interface to set the cache threshold that the media player needs to resume playback.void
setNetWorkResourceMaxCache(int time, int size)
Set the maximum cache duration and cache data size of web materials.void
setPlayerCanvas(ZegoCanvas canvas)
Set the view of the player playing video.void
setPlayMediaStreamType(ZegoMediaStreamType streamType)
Set play media stream type.void
setPlaySpeed(float speed)
Set the speed of play.void
setPlayVolume(int volume)
Set mediaplayer local playback volume.void
setProgressInterval(long millisecond)
Set playback progress callback interval.void
setPublishVolume(int volume)
Set mediaplayer publish volume.void
setVideoHandler(IZegoMediaPlayerVideoHandler handler, ZegoVideoFrameFormat frameFormat)
Set video data callback handler of the media player.void
setVoiceChangerParam(ZegoMediaPlayerAudioChannel audioChannel, ZegoVoiceChangerParam param)
[Deprecated] Setting up the specific voice changer parameters.void
setVolume(int volume)
Set mediaplayer volume.void
start()
Start playing.void
stop()
Stop playing.void
takeSnapshot(IZegoMediaPlayerTakeSnapshotCallback callback)
Take a screenshot of the current playing screen of the media player.void
updatePosition(float[] position)
Update the position of the media player (audio source).
-
-
-
Field Detail
-
mUIHandler
public static android.os.Handler mUIHandler
-
mediaplayerToIdxAndEventhandler
public static java.util.concurrent.ConcurrentHashMap<ZegoMediaPlayer,im.zego.zegoexpress.internal.ZegoMediaPlayerInternalImpl.IdxAndHandler> mediaplayerToIdxAndEventhandler
-
-
Method Detail
-
setEventHandler
public void setEventHandler(IZegoMediaPlayerEventHandler handler)
Description copied from class:ZegoMediaPlayer
Set event notification callback handler of the media player. Available since: 2.1.0 Description: Listen to the event notification callback of the media player. Use Cases: You can change the media player UI widget according to the related event callback. When to call: After the [ZegoMediaPlayer] instance created. Restrictions: None. Caution: Calling this function will overwrite the callback set by the last call to this function.- Specified by:
setEventHandler
in classZegoMediaPlayer
- Parameters:
handler
- Event callback handler for media player
-
setVideoHandler
public void setVideoHandler(IZegoMediaPlayerVideoHandler handler, ZegoVideoFrameFormat frameFormat)
Description copied from class:ZegoMediaPlayer
Set video data callback handler of the media player. Available since: 2.1.0 Description: By setting this callback, the video data of the media resource file played by the media player can be called back. When to call: After the [ZegoMediaPlayer] instance created. Restrictions: None. Caution: When you no longer need to get the video frame data, please call this function again to clear the handler to stop the video frame data callback.- Specified by:
setVideoHandler
in classZegoMediaPlayer
- Parameters:
handler
- Video data callback handler for media playerframeFormat
- Video frame format for video data
-
setAudioHandler
public void setAudioHandler(IZegoMediaPlayerAudioHandler handler)
Description copied from class:ZegoMediaPlayer
Set audio data callback handler of the media player. Available since: 2.1.0 Description: By setting this callback, the audio data of the media resource file played by the media player can be called back. When to call: After the [ZegoMediaPlayer] instance created. Restrictions: None. Caution: When you no longer need to get the audio data, please call this function again to clear the handler to stop the audio data callback.- Specified by:
setAudioHandler
in classZegoMediaPlayer
- Parameters:
handler
- Audio data callback handler for media player
-
setBlockDataHandler
public void setBlockDataHandler(IZegoMediaPlayerBlockDataHandler handler, int blockSize)
Description copied from class:ZegoMediaPlayer
Set the media resource block data callback handler of the media player. Available since: 3.4.0 Description: This callback can be set to listen to and decrypt the media resource block data for playing the user's own ciphertext media resources. When to call: After the [ZegoMediaPlayer] instance created, before playing media resources. Restrictions: None. Caution: When it is no longer necessary to listen to the callback for data decryption, please call this function again to clear the handler.- Specified by:
setBlockDataHandler
in classZegoMediaPlayer
- Parameters:
handler
- The media resource block data callback handler of the media player.blockSize
- The size of the encrypted data block. The bufferSize in the OnBlockData callback is an integer multiple of blockSize.
-
loadResource
public void loadResource(java.lang.String path, IZegoMediaPlayerLoadResourceCallback callback)
Description copied from class:ZegoMediaPlayer
Load local or network media resource. Available: since 1.3.4 Description: Load media resources. Use case: Developers can load the absolute path to the local resource or the URL of the network resource incoming. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Related APIs: Resources can be loaded through the [loadResourceWithPosition] or [loadResourceFromMediaData] function. Caution: If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.- Specified by:
loadResource
in classZegoMediaPlayer
- Parameters:
path
- The absolute resource path or the URL of the network resource and cannot be null or "". Android can set this path string with Uri.callback
- Notification of resource loading results
-
loadResourceWithPosition
public void loadResourceWithPosition(java.lang.String path, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Description copied from class:ZegoMediaPlayer
Load local or network media resource and specify the start position. Available: since 2.14.0 Description: Load media resources, and specify the progress, in milliseconds, at which playback begins. Use case: Developers can load the absolute path to the local resource or the URL of the network resource incoming. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Related APIs: Resources can be loaded through the [loadResource] or [loadResourceFromMediaData] function. Caution: 1.When [startPosition] exceeds the total playing time, it will start playing from the beginning. 2.If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.- Specified by:
loadResourceWithPosition
in classZegoMediaPlayer
- Parameters:
path
- The absolute resource path or the URL of the network resource and cannot be null or "". Android can set this path string with Uri.startPosition
- The progress at which the playback started.callback
- Notification of resource loading results
-
loadResourceFromMediaData
public void loadResourceFromMediaData(byte[] mediaData, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Description copied from class:ZegoMediaPlayer
Load binary audio resource. Available: since 2.10.0 Description: Load binary audio data. Use case: Developers do not want to cache the audio data locally, and directly transfer the audio binary data to the media player, directly load and play the audio. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Related APIs: Resources can be loaded through the [loadResource] or [loadResourceWithPosition] function. Caution: 1.When [startPosition] exceeds the total playing time, it will start playing from the beginning. 2.If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.- Specified by:
loadResourceFromMediaData
in classZegoMediaPlayer
- Parameters:
mediaData
- Binary audio data.startPosition
- Position of starting playback, in milliseconds.callback
- Notification of resource loading results.
-
loadCopyrightedMusicResourceWithPosition
public void loadCopyrightedMusicResourceWithPosition(java.lang.String resourceId, long startPosition, IZegoMediaPlayerLoadResourceCallback callback)
Description copied from class:ZegoMediaPlayer
Load copyrighted music resource. Available: since 2.14.0 Description: Load media resources, and specify the progress, in milliseconds, at which playback begins. Use case: Developers can load the resource ID of copyrighted music. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Caution: 1.When [startPosition] exceeds the total playing time, it will start playing from the beginning. 2.If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.- Specified by:
loadCopyrightedMusicResourceWithPosition
in classZegoMediaPlayer
- Parameters:
resourceId
- The resource ID obtained from the copyrighted music module.startPosition
- The progress at which the playback started.callback
- Notification of resource loading results
-
loadResourceWithConfig
public void loadResourceWithConfig(ZegoMediaPlayerResource resource, IZegoMediaPlayerLoadResourceCallback callback)
Description copied from class:ZegoMediaPlayer
Load local or network media resource with config. Available: since 3.3.0 Description: Load media resources. Use case: Developers can load the absolute path to the local resource or the URL of the network resource incoming. When to call: Called after the engine [createEngine] has been initialized and the media player [createMediaPlayer] has been created. Related APIs: Support for loading resources through the [loadResourceWithPosition] or [loadResourceFromMediaData] interface. Caution: If the mediaplayer has already loaded resources or is in the process of playing, please first call the [stop] interface to halt the playback, and then proceed to call the interface to load the media resources; failure to do so will result in an unsuccessful load.- Specified by:
loadResourceWithConfig
in classZegoMediaPlayer
- Parameters:
resource
- Multimedia resources that need to be loaded.callback
- Notification of resource loading results
-
getIndex
public int getIndex()
Description copied from class:ZegoMediaPlayer
Get media player index. Description: Get media player index. When to call: It can be called after [createMediaPlayer]. Restrictions: None.- Specified by:
getIndex
in classZegoMediaPlayer
- Returns:
- Media player index.
-
start
public void start()
Description copied from class:ZegoMediaPlayer
Start playing. You need to load resources before playing- Specified by:
start
in classZegoMediaPlayer
-
stop
public void stop()
Description copied from class:ZegoMediaPlayer
Stop playing.- Specified by:
stop
in classZegoMediaPlayer
-
pause
public void pause()
Description copied from class:ZegoMediaPlayer
Pause playing.- Specified by:
pause
in classZegoMediaPlayer
-
resume
public void resume()
Description copied from class:ZegoMediaPlayer
Resume playing.- Specified by:
resume
in classZegoMediaPlayer
-
seekTo
public void seekTo(long millisecond, IZegoMediaPlayerSeekToCallback callback)
Description copied from class:ZegoMediaPlayer
Set the specified playback progress. Unit is millisecond- Specified by:
seekTo
in classZegoMediaPlayer
- Parameters:
millisecond
- Point in time of specified playback progresscallback
- The result notification of set the specified playback progress
-
enableRepeat
public void enableRepeat(boolean enable)
Description copied from class:ZegoMediaPlayer
Whether to repeat playback.- Specified by:
enableRepeat
in classZegoMediaPlayer
- Parameters:
enable
- repeat playback flag. The default is false.
-
enableAux
public void enableAux(boolean enable)
Description copied from class:ZegoMediaPlayer
Whether to mix the player's sound into the stream being published. This interface will only mix the media player sound into the main channel- Specified by:
enableAux
in classZegoMediaPlayer
- Parameters:
enable
- Aux audio flag. The default is false.
-
muteLocal
public void muteLocal(boolean mute)
Description copied from class:ZegoMediaPlayer
Whether to play locally silently. If [enableAux] switch is turned on, there is still sound in the publishing stream. The default is false.- Specified by:
muteLocal
in classZegoMediaPlayer
- Parameters:
mute
- Mute local audio flag, The default is false.
-
setPlayerCanvas
public void setPlayerCanvas(ZegoCanvas canvas)
Description copied from class:ZegoMediaPlayer
Set the view of the player playing video. Note: This function is only available in ZegoExpressVideo SDK!- Specified by:
setPlayerCanvas
in classZegoMediaPlayer
- Parameters:
canvas
- Video rendered canvas object
-
setVolume
public void setVolume(int volume)
Description copied from class:ZegoMediaPlayer
Set mediaplayer volume. Both the local play volume and the publish volume are set.- Specified by:
setVolume
in classZegoMediaPlayer
- Parameters:
volume
- The range is 0 ~ 200. The default is 60.
-
setPlaySpeed
public void setPlaySpeed(float speed)
Description copied from class:ZegoMediaPlayer
Set the speed of play. Available since: 2.12.0 Description: Set the playback speed of the player. When to call: You should load resource before invoking this function. Restrictions: None. Related APIs: Resources can be loaded through the [loadResource] function.- Specified by:
setPlaySpeed
in classZegoMediaPlayer
- Parameters:
speed
- The speed of play. The default is 1.0. Versions 2.12.0 to 3.15.1: The range is 0.5 ~ 4.0. Versions 3.16.0 and above: The range is 0.3 ~ 4.0.
-
setProgressInterval
public void setProgressInterval(long millisecond)
Description copied from class:ZegoMediaPlayer
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- Specified by:
setProgressInterval
in classZegoMediaPlayer
- Parameters:
millisecond
- Interval of playback progress callback in milliseconds
-
setPlayVolume
public void setPlayVolume(int volume)
Description copied from class:ZegoMediaPlayer
Set mediaplayer local playback volume.- Specified by:
setPlayVolume
in classZegoMediaPlayer
- Parameters:
volume
- The range is 0 ~ 200. The default is 60.
-
setPublishVolume
public void setPublishVolume(int volume)
Description copied from class:ZegoMediaPlayer
Set mediaplayer publish volume.- Specified by:
setPublishVolume
in classZegoMediaPlayer
- Parameters:
volume
- The range is 0 ~ 200. The default is 60.
-
getPlayVolume
public int getPlayVolume()
Description copied from class:ZegoMediaPlayer
Gets the current local playback volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.- Specified by:
getPlayVolume
in classZegoMediaPlayer
- Returns:
- current volume
-
getPublishVolume
public int getPublishVolume()
Description copied from class:ZegoMediaPlayer
Gets the current publish volume of the mediaplayer, the range is 0 ~ 200, with the default value of 60.- Specified by:
getPublishVolume
in classZegoMediaPlayer
- Returns:
- current volume
-
getTotalDuration
public long getTotalDuration()
Description copied from class:ZegoMediaPlayer
Get the total progress of your media resources. You should load resource before invoking this function, otherwise the return value is 0- Specified by:
getTotalDuration
in classZegoMediaPlayer
- Returns:
- Unit is millisecond
-
getCurrentProgress
public long getCurrentProgress()
Description copied from class:ZegoMediaPlayer
Get current playing progress. You should load resource before invoking this function, otherwise the return value is 0- Specified by:
getCurrentProgress
in classZegoMediaPlayer
- Returns:
- current progress
-
getCurrentRenderingProgress
public long getCurrentRenderingProgress()
Description copied from class:ZegoMediaPlayer
Get current rendering progress. You should load resource before invoking this function, otherwise the return value is 0- Specified by:
getCurrentRenderingProgress
in classZegoMediaPlayer
- Returns:
- current rendering progress
-
getAudioTrackCount
public int getAudioTrackCount()
Description copied from class:ZegoMediaPlayer
Get the number of audio tracks of the playback file.- Specified by:
getAudioTrackCount
in classZegoMediaPlayer
- Returns:
- Number of audio tracks
-
setAudioTrackIndex
public void setAudioTrackIndex(int index)
Description copied from class:ZegoMediaPlayer
Set the audio track of the playback file.- Specified by:
setAudioTrackIndex
in classZegoMediaPlayer
- Parameters:
index
- Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.
-
setAudioTrackMode
public void setAudioTrackMode(ZegoMediaPlayerAudioTrackMode mode)
Description copied from class:ZegoMediaPlayer
Set the audio track mode of the player. Available since: 3.1.0 Description: Set the audio track mode of the player. Use case: Under the real-time chorus (KTV), call the interface enable multi-track mode, call the interface [setAudioTrackIndex] to specify the original track to play, call interface [setAudioTrackPublishIndex] specified need publish of accompaniment tracks. When to call: The call takes effect before [start] starts playing Related APIs: Call [setAudioTrackIndex] to specified the play track of media file and call [setAudioTrackPublishIndex] to specified the publish track of media file. Caution: When multi-track mode is enabled, the resource consumption of the hardware device is increased.- Specified by:
setAudioTrackMode
in classZegoMediaPlayer
- Parameters:
mode
- Audio track mode.
-
setAudioTrackPublishIndex
public void setAudioTrackPublishIndex(int index)
Description copied from class:ZegoMediaPlayer
Set the audio track for the media file to be publish. Available since: 3.1.0 Description: Set the audio track for the media file to be publish. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Related APIs: The number of audio tracks can be obtained through the [getAudioTrackCount] function. Caution: This call takes effect only after multitrack mode is enabled by calling the interface [setAudioTrackMode].- Specified by:
setAudioTrackPublishIndex
in classZegoMediaPlayer
- Parameters:
index
- Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.
-
setVoiceChangerParam
public void setVoiceChangerParam(ZegoMediaPlayerAudioChannel audioChannel, ZegoVoiceChangerParam param)
Description copied from class:ZegoMediaPlayer
[Deprecated] Setting up the specific voice changer parameters.- Specified by:
setVoiceChangerParam
in classZegoMediaPlayer
- Parameters:
audioChannel
- The audio channel to be voice changedparam
- Voice changer parameters
-
enableVoiceChanger
public void enableVoiceChanger(ZegoMediaPlayerAudioChannel audioChannel, boolean enable, ZegoVoiceChangerParam param)
Description copied from class:ZegoMediaPlayer
Enable voice changer, set up the specific voice changer parameters. Available since: 3.15.0 Description: Enable voice changer, set up the specific voice changer parameters. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].- Specified by:
enableVoiceChanger
in classZegoMediaPlayer
- Parameters:
audioChannel
- The audio channel to be voice changedenable
- Whether enable voice changer or not. True - enabled, false - disabled, default value is false.param
- Voice changer parameters
-
createMediaPlayer
public static ZegoMediaPlayer createMediaPlayer()
-
destroyMediaPlayer
public static void destroyMediaPlayer(ZegoMediaPlayer mediaplayer)
-
destroyAllMediaPlayer
public static void destroyAllMediaPlayer()
-
getCurrentState
public ZegoMediaPlayerState getCurrentState()
Description copied from class:ZegoMediaPlayer
Get the current playback status.- Specified by:
getCurrentState
in classZegoMediaPlayer
- Returns:
- current state
-
takeSnapshot
public void takeSnapshot(IZegoMediaPlayerTakeSnapshotCallback callback)
Description copied from class:ZegoMediaPlayer
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 Note: This function is only available in ZegoExpressVideo SDK!- Specified by:
takeSnapshot
in classZegoMediaPlayer
- Parameters:
callback
- The callback of the screenshot of the media player playing screen
-
enableAccurateSeek
public void enableAccurateSeek(boolean enable, ZegoAccurateSeekConfig config)
Description copied from class:ZegoMediaPlayer
Enable accurate seek and set relevant attributes. Available since: 2.4.0 Description: The timestamp specified by normal seek may not an I frame, and then returns the I frame near the specified timestamp, which is not so accurate. But the accurate seek, when the specified timestamp is not an I frame, it will use the I frame near the specified timestamp to decode the frame of the specified timestamp. Use cases: When user needs to seek to the specified timestamp accurately. When to call: The setting must be called before [loadResource], and it will take effect during the entire life cycle of the media player.- Specified by:
enableAccurateSeek
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable accurate seekconfig
- The property setting of accurate seek, only valid when enable is true.
-
setNetWorkResourceMaxCache
public void setNetWorkResourceMaxCache(int time, int size)
Description copied from class:ZegoMediaPlayer
Set the maximum cache duration and cache data size of web materials. The setting must be called before loading the resource, and it will take effect during the entire life cycle of the media player. Time and size are not allowed to be 0 at the same time. The SDK internal default time is 5000, and the size is 15*1024*1024 byte.When one of time and size reaches the set value first, the cache will stop.- Specified by:
setNetWorkResourceMaxCache
in classZegoMediaPlayer
- Parameters:
time
- The maximum length of the cache time, in ms, the SDK internal default is 5000; the effective value is greater than or equal to 2000; if you fill in 0, it means no limit.size
- The maximum size of the cache, the unit is byte, the internal default size of the SDK is 15*1024*1024 byte; the effective value is greater than or equal to 5000000, if you fill in 0, it means no limit.
-
getNetWorkResourceCache
public ZegoNetWorkResourceCache getNetWorkResourceCache()
Description copied from class:ZegoMediaPlayer
Get the playable duration and size of the cached data of the current network material cache queue- Specified by:
getNetWorkResourceCache
in classZegoMediaPlayer
- Returns:
- Returns the current cached information, including the length of time the data can be played and the size of the cached data.
-
setNetWorkBufferThreshold
public void setNetWorkBufferThreshold(int threshold)
Description copied from class:ZegoMediaPlayer
Use this interface to set the cache threshold that the media player needs to resume playback. The SDK default value is 5000ms,The valid value is greater than or equal to 1000ms The setting must be called before loading the resource, and it will take effect during the entire life cycle of the media player. When the network status is poor and the media player has finished playing the cached network resources, it will stop playing, and notify the user through the `ZegoMediaPlayerNetworkEvent.BUFFER_BEGIN` state of the callback interface `onMediaPlayerNetworkEvent` that the network resources are being recached. Only when the cached network resources are greater than the set threshold, the media player will automatically resume playback at the original paused position, and notify the user through the `ZegoMediaPlayerNetworkEvent.BUFFER_ENDED` of the callback interface `onMediaPlayerNetworkEvent` that the user has cached the network resources The threshold was reached and playback resumed.- Specified by:
setNetWorkBufferThreshold
in classZegoMediaPlayer
- Parameters:
threshold
- Threshold that needs to be reached to resume playback, unit ms.
-
enableSoundLevelMonitor
public void enableSoundLevelMonitor(boolean enable, int millisecond)
Description copied from class:ZegoMediaPlayer
Whether to enable sound level monitoring. Available since: 2.15.0 Description: Whether to enable sound level monitoring. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: None. Related callbacks: After it is turned on, user can use the [onMediaPlayerSoundLevelUpdate] callback to monitor sound level updates.- Specified by:
enableSoundLevelMonitor
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable monitoring, true is enabled, false is disabled.millisecond
- Monitoring time period of the sound level, in milliseconds, has a value range of [100, 3000].
-
enableFrequencySpectrumMonitor
public void enableFrequencySpectrumMonitor(boolean enable, int millisecond)
Description copied from class:ZegoMediaPlayer
Whether to enable frequency spectrum monitoring. Available since: 2.15.0 Description: Whether to enable frequency spectrum monitoring. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: None. Related APIs: After it is turned on, user can use the [onMediaPlayerFrequencySpectrumUpdate] callback to monitor frequency spectrum updates.- Specified by:
enableFrequencySpectrumMonitor
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable monitoring, true is enabled, false is disabled.millisecond
- Monitoring time period of the frequency spectrum, in milliseconds, has a value range of [100, 3000].
-
setActiveAudioChannel
public void setActiveAudioChannel(ZegoMediaPlayerAudioChannel audioChannel)
Description copied from class:ZegoMediaPlayer
Set the playback channel. Available since: 2.20.0 Description: Set the playback channel. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: None.- Specified by:
setActiveAudioChannel
in classZegoMediaPlayer
- Parameters:
audioChannel
- Playback channel, the default is ZegoMediaPlayerAudioChannelAll.
-
clearView
public void clearView()
Description copied from class:ZegoMediaPlayer
Clears the last frame of the playback control that remains on the control after playback ends. Available since: 2.20.0 Description: Clears the last frame of the playback control that remains on the control after playback ends. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: The interface call takes effect only when the media player ends playing.- Specified by:
clearView
in classZegoMediaPlayer
-
getMediaInfo
public ZegoMediaPlayerMediaInfo getMediaInfo()
Description copied from class:ZegoMediaPlayer
Get meida information such as video resolution from media file. Available since: 3.6.0 Description: Get meida information such as video resolution from media file. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: None.- Specified by:
getMediaInfo
in classZegoMediaPlayer
-
updatePosition
public void updatePosition(float[] position)
Description copied from class:ZegoMediaPlayer
Update the position of the media player (audio source). Available since: 3.6.0 Description: Update the position of the media player (audio source). Use cases: The media player also needs to have 3D spatial sound. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: This interface needs to be used in conjunction with the RangeAudio/RangeScene module. This interface can only be called successfully after the RangeAudio/RangeScene module enables 3D sound effects.- Specified by:
updatePosition
in classZegoMediaPlayer
- Parameters:
position
- The unit vector of the front axis of its own coordinate system. The parameter is a float array with a length of 3.
-
setHttpHeader
public void setHttpHeader(java.util.HashMap<java.lang.String,java.lang.String> headers)
Description copied from class:ZegoMediaPlayer
Set http headers. Available since: 3.8.0 Description: Call this function to set the http headers of the http network resource. Use cases: When the network resource needs to set special header information. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: Called before the corresponding network resource is loaded.- Specified by:
setHttpHeader
in classZegoMediaPlayer
- Parameters:
headers
- Headers info.
-
enableLiveAudioEffect
public void enableLiveAudioEffect(boolean enable, ZegoLiveAudioEffectMode mode)
Description copied from class:ZegoMediaPlayer
Enable live audio effect. Available since: 3.10.0 Description: When the live audio effect is turned on, the spatial sense is enhanced and the instrument sounds become more prominent, without any increase in delay. Use cases: It is commonly used in voice chat rooms and karaoke scenarios to enhance the live audio effects of the accompaniment. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Caution: To enhance the live audio effect experience, it is recommended to configure dual-channel stereo encoding. Developers can achieve this configuration by using the [setAudioCaptureStereoMode] method. Failure to configure dual-channel stereo encoding may significantly diminish the effects of certain songs, as the left and right channel effects may cancel each other out when synthesizing mono audio, resulting in less noticeable effects.- Specified by:
enableLiveAudioEffect
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable live audio effect.mode
- Live audio effect mode.
-
enableLocalCache
public void enableLocalCache(boolean enable, java.lang.String cacheDir)
Description copied from class:ZegoMediaPlayer
Enable local caching of http/https network resources. Available since: 3.12.0 Description: When playing http/https network resources, when the local cache is enabled, the network resources will be saved locally and the cache information will be called back through [onMediaPlayerLocalCache]. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Called after [loadResource] or during playback, it will take effect next playback. Caution: Only http/https single file type network resources are supported. If there is a [seek] operation during playback, the cache will fail.- Specified by:
enableLocalCache
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable local caching.cacheDir
- Cache dir. If left blank, the directory specified internally by SDK will be used.
-
enableViewMirror
public void enableViewMirror(boolean enable)
Description copied from class:ZegoMediaPlayer
Enable the view mirror. Available since: 3.14.0 Description: Enable view mirror. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer].- Specified by:
enableViewMirror
in classZegoMediaPlayer
- Parameters:
enable
- Whether to enable view mirror.
-
setPlayMediaStreamType
public void setPlayMediaStreamType(ZegoMediaStreamType streamType)
Description copied from class:ZegoMediaPlayer
Set play media stream type. Available since: 3.10.0 Description: Configure the media stream type to be played. You can only play video streams or audio streams. This will take effect during the life cycle of the media player. Use cases: When the network resource needs to set special header information. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Caution: Changing the media stream type during playing will take effect in the next playing.- Specified by:
setPlayMediaStreamType
in classZegoMediaPlayer
- Parameters:
streamType
- Stream type.
-
getPlaybackStatistics
public ZegoMediaPlayerStatisticsInfo getPlaybackStatistics()
Description copied from class:ZegoMediaPlayer
Get playback statistics. Available since: 3.12.0 Description: Get current playback statistics to monitor whether decoding and rendering anomalies occur in the player. Use cases: Typically used in cloud-based media player scenarios. When to call: Invoke after the [loadResource] callback succeeds.- Specified by:
getPlaybackStatistics
in classZegoMediaPlayer
-
-