Media Player Kit v1.3.0 API Reference for Windows
|
Public Member Functions | |
virtual int | initialize (const MediaPlayerContext &context)=0 |
virtual int | open (const char *src, int64_t startPos)=0 |
virtual int | play ()=0 |
virtual int | pause ()=0 |
virtual int | stop ()=0 |
virtual int | seek (int64_t pos)=0 |
virtual int | mute (bool mute)=0 |
virtual int | getMute (bool &mute)=0 |
virtual int | adjustPlayoutVolume (int volume)=0 |
virtual int | getPlayoutVolume (int &volume)=0 |
virtual int | getDuration (int64_t &duration)=0 |
virtual int | getPlayPosition (int64_t &pos)=0 |
virtual int | getStreamCount (int64_t &count)=0 |
virtual int | getStreamInfo (int64_t index, media::base::MediaStreamInfo *info)=0 |
virtual media::base::MEDIA_PLAYER_STATE | getState ()=0 |
virtual int | setView (media::base::view_t view)=0 |
virtual int | setRenderMode (media::base::RENDER_MODE_TYPE renderMode)=0 |
virtual int | registerPlayerObserver (IMediaPlayerObserver *observer)=0 |
virtual int | unregisterPlayerObserver (IMediaPlayerObserver *observer)=0 |
virtual int | registerVideoFrameObserver (media::base::IVideoFrameObserver *observer)=0 |
virtual int | unregisterVideoFrameObserver (agora::media::base::IVideoFrameObserver *observer)=0 |
virtual int | registerAudioFrameObserver (media::base::IAudioFrameObserver *observer)=0 |
virtual int | unregisterAudioFrameObserver (agora::media::base::IAudioFrameObserver *observer)=0 |
virtual int | setLogFile (const char *filePath)=0 |
virtual int | setLogFilter (unsigned int filter)=0 |
virtual int | changePlaybackSpeed (media::base::MEDIA_PLAYER_PLAYBACK_SPEED speed)=0 |
virtual int | selectAudioTrack (int index)=0 |
virtual int | setPlayerOption (const char *key, int value)=0 |
virtual int | setPlayerOption (const char *key, const char *value)=0 |
virtual int | setExternalSubtitle (const char *url)=0 |
virtual int | setPlayerOption (const char *key, const char *value)=0 |
virtual int | setLoopCount (int loopCount)=0 |
virtual const char * | getPlayerSdkVersion ()=0 |
virtual int | switchSrc (const char *src, bool syncPts=true)=0 |
virtual int | addPreloadSrc (const char *src, int64_t startPos)=0 |
virtual int | playPreload (const char *src)=0 |
virtual void | release (bool sync=true)=0 |
Protected Member Functions | |
virtual | ~IMediaPlayer ()=default |
The IMediaPlayer class.
|
protectedvirtualdefault |
|
pure virtual |
Initializes the MediaPlayer Kit service.
context | The MediaPlayer Kit context. See MediaPlayerContext for details. |
|
pure virtual |
Opens the media resource.
src | The path of the media resource. Both local path and online path are supported. |
startPos | The starting position (ms) for playback. Default value is 0. |
|
pure virtual |
Plays the media resource.
After open() or pause() or seek(), you can call this method to play the media resource.
|
pure virtual |
Pauses the playback.
To resume the playback, call the play() method.
|
pure virtual |
Stops the playback.
|
pure virtual |
Seeks to a new playback position.
After successfully calling the method, you will receive the onPlayerEvent callback, reporting the result of the seek operation to the new playback position.
pos | The new playback position (ms). |
|
pure virtual |
Sets whether to mute the media resource.
mute | Sets whether to mute the media resource:
|
|
pure virtual |
Checks whether the media resource is muted.
[out] | mute | Whether the media resource is muted:
|
|
pure virtual |
Adjusts the local playback volume.
volume | The local playback volume, which ranges from 0 to 100:
|
|
pure virtual |
Gets current local playback volume.
[out] | volume | The local playback volume, which ranges from 0 to 100:
|
|
pure virtual |
Gets the duration of the media resource.
[out] | duration | The total duration (ms) of the media resource. |
|
pure virtual |
Gets current playback progress.
[out] | pos | The playback progress (ms). |
|
pure virtual |
Gets the number of the media streams in the media resource.
[out] | count | The number of the media streams in the media resource. |
|
pure virtual |
Gets the detailed information of the media stream.
index | The index of the media stream. | |
[out] | info | The detailed information of the media stream. See MediaStreamInfo for details. |
|
pure virtual |
Gets current playback state.
|
pure virtual |
Sets the player's render view.
view | The player's render view (HWND). |
|
pure virtual |
Sets the player's render mode.
renderMode | The player's render mode
|
|
pure virtual |
Registers a player observer.
observer | The player observer, listening for events during the playback. See IMediaPlayerObserver for details. |
|
pure virtual |
Unregisters a player observer.
observer | The player observer, listening for events during the playback. See IMediaPlayerObserver for details. |
|
pure virtual |
Registers a video observer.
observer | The video observer, reporting the reception of each video frame. See IVideoFrameObserver for details. |
|
pure virtual |
Unregisters a video observer.
observer | The video observer, reporting the reception of each video frame. See IVideoFrameObserver for details. |
|
pure virtual |
Registers an audio observer.
observer | The audio observer, reporting the reception of each audio frame. See IAudioFrameObserver for details. |
|
pure virtual |
Unregisters an audio observer.
observer | The audio observer, reporting the reception of each audio frame. See IAudioFrameObserver for details. |
|
pure virtual |
Sets the output path of the log file.
The log generated during the mediaplayer kit runtime records in the log file. To set the storage path of the log file, call this method. Ensure that the path you specified exists and is writable. If you don't call this method, the log file records in the log file to the default path: "C:\Users\{user_name}\AppData\Local\Agora\{project_name}".
filePath | Absolute path of the log file, which is UTF-8 encoded. |
|
pure virtual |
Sets the output level of the log file.
Sets the filter level of the output log for the MediaPlayer Kit. The filter levels from low to high are OFF, DEBUG, INFO, WARN, ERROR, and CRITICAL respectively. Sets a filter level and you can get the log for all levels prior to that level. See filter
for details.
filter | The filter level of the output log file.
|
|
pure virtual |
Adjusts the playback speed.
Call this method after the play() method.
speed | The playback speed. See MEDIA_PLAYER_PLAYBACK_SPEED for details |
|
pure virtual |
Selects the audio track.
When the media resource contains more than one audio track, you can call this method to select which audio track to use.
index | The index of the audio track. |
|
pure virtual |
Sets the private options for the MediaPlayer Kit.
The MediaPlayer Kit supports setting private options by providing key
and value
. Under normal circumstances, you do not need to know the private option settings, and just use the default option settings.
key | key. |
value | value. |
|
pure virtual |
Sets the private options for the MediaPlayer Kit.
The MediaPlayer Kit supports setting private options by providing key
and value
. Under normal circumstances, you do not need to know the private option settings, and just use the default option settings.
key | key. |
value | value. |
|
pure virtual |
Sets the external subtitle.
After opening the media file, you can call this method set the mediaplayer kit to display the external subtitle.
url | The URL address of the external subtitle. Both SRT subtitle and ASS subtitle, local address and online address are supported. |
|
pure virtual |
Sets the private options for the MediaPlayer Kit.
The MediaPlayer Kit supports setting private options by providing key
and value
. Under normal circumstances, you do not need to know the private option settings, and just use the default option settings.
key | key. |
value | value. |
|
pure virtual |
Sets the loop playback.
If you want to loop, call this method and set the number of the loops.
When the loop playback ends, MediaPlayer Kit returns PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED
.
loopCount | The number of the loops. |
|
pure virtual |
Gets the version number of the MediaPlayer Kit.
"1.2.1"
.
|
pure virtual |
Switches the media resource being played.
You can call this method to switch the media resource to be played according to the current network status. For example, when the network is poor, the media resource to be played is switched to a media resource address with a lower bitrate; when the network is good, the media resource to be played is switched to a media resource address with a higher bitrate.
After calling switchSrc
, if you receive the onPlayerEvent callback event PLAYER_EVENT_SWITCH_COMPLETE
, the switch is successful; if you receive the onPlayerEvent callback event PLAYER_EVENT_SWITCH_ERROR
, the switch fails.
switchSrc(src, true)
:src | The URL address of the media resource to be switched. HTTP, RTMP, and RTSP protocols are supported for local and online media streams. |
syncPts | Whether to synchronize the playback position(millionseconds) before and after the switch:
|
|
pure virtual |
Preloads media resources.
You can call this method to preload a media resource into the playlist. If you need to preload multiple media resources, you can call this method multiple times.
After calling addPreloadSrc
, if you receive the onPreloadEvent callback event PLAYER_PRELOAD_EVENT_COMPLETE
, the preload is successful; if you receive the onPreloadEvent callback event PLAYER_PRELOAD_EVENT_ERROR
, the preload fails.
After the preload is successful, if you want to play the media resource, call playPreload; if you want to clear the playlist, call stop.
src | The URL address of the preloaded media resource. HTTP, RTMP, and RTSP protocols are supported for local and online media streams. |
startPos | The starting position (milliseconds) when starting to play after preloading to the playlist. When preloading a live stream, set startPos to 0. |
|
pure virtual |
Plays preloaded media resources.
This method only supports playing media resources that have been preloaded into the playlist. After calling this method, if you receive the onPlayerStateChanged callback to report the state PLAYER_STATE_PLAYING
, the playback is successful.
If you want to change the preloaded media resource to be played, you can call this method again and specify a new media resource path. If you want to replay the media resource, you need to call addPreloadSrc to preload the media resource to the playlist again before playing.. If you want to clear the playlist, call stop.
src | The URL address of the media resource in the playlist. This address must be consistent with the src set by the addPreloadSrc method; otherwise, the media resource cannot be played. |
|
pure virtual |
Releases the IMediaPlayer resource.