The RtcEngine
is defined in io.agora.rtc
.
private native long nativeCreateMediaPlayer();
Creates an IMediaPlayer
instance.
Returns
The IMediaPlayer
instance.
private native int nativeDestroy(long mediaPlayerNativeHandle);
Destroys an IMediaPlayer
instance.
Returns
public void publishPlayerAudio(){
synchronized(RtcMediaPlayerPlugin.class){
if(rtcEngineNativeHandle != 0){
RtcMediaPlayerPlugin.nativePublishPlayerAudio(mediaPlayerNativeHandle);
}
}
}
Publishes the audio of the media resources.
public void publishPlayerVideo(){
synchronized(RtcMediaPlayerPlugin.class){
if(rtcEngineNativeHandle != 0){
RtcMediaPlayerPlugin.nativePublishPlayerVideo(mediaPlayerNativeHandle);
}
}
}
Publishes the video of the media resources.
public void unpublishPlayerAudio(){
synchronized(RtcMediaPlayerPlugin.class){
if(rtcEngineNativeHandle != 0){
RtcMediaPlayerPlugin.nativeUnpublishPlayerAudio(mediaPlayerNativeHandle);
}
}
}
Stop publishing the audio of the media resources.
public void unpublishPlayerVideo(){
synchronized(RtcMediaPlayerPlugin.class){
if(rtcEngineNativeHandle != 0){
RtcMediaPlayerPlugin.nativeUnpublishPlayerVideo(mediaPlayerNativeHandle);
}
}
}
Stop publishing the video of the media resources.
int open(String url, long startPos);
Opens the media resource.
API comparison
f you want to open the media resource, call the open
method. If you want to open the media resource and choose the CDN route for playing to improve the viewing experience, call the openWithAgoraCDNSrc
method.
Parameters
url
: The url of the media resource.startPos
: The starting position (ms) for playback. Default value is 0.Returns
int openWithCustomSource(long startPos, IMediaPlayerCustomDataProvider provider);
Opens the media resource through a custom URL.
API comparison
Compared with open
and openWithAgoraCDNSrc
, openWithCustomSource
allows you to open the media resource through a custom URL; for example, you can call this method to open an encrypted media file.
Parameters
startPos
: The starting position (ms) for playback. Default value is 0.provider
: The custom media resource. See IMediaPlayerCustomDataProvider
for details.Returns
int openWithAgoraCDNSrc(String src, long startPos);
Opens the media resource.
After you call this method, Agora tries to obtain all the CDN routes for playing the media resource. By default, Agora uses the first CDN route for playing, and you can call the switchAgoraCDNLineByIndex
method to change routes.
API comparison
If you want to open the media resource, call the open
method. If you want to open the media resource and choose the CDN route for playing to improve the viewing experience, call the openWithAgoraCDNSrc
method.
Authentication
If you need to want the security of the media files to be played, contact support@agora.io to determine the sign
and the ts
field for authentication. To obtain the authenticated URL of the media resource, you need to use these two fields as the query parameters. The following is an example:
rtmp://$domain/$appName/$streamName
rtmp://$domain/$appName/$streamName?ts=$ts&sign=$sign
Authentication information:
sign
: An encrypted string calculated according to the md5 algorithm based on authKey
,appName
,streamName
and ts
. You need to contact support@agora.io for your authKey
.ts
: The timestamp when the authentication information expires. You can set the validity period of the authentication information according to your scenarios, for example, 24 hours or 1h30m20s.Parameters
src
: The URL of the media resource.startPos
: The starting position (ms) for playback. The default value is 0. This value can be empty if the media resource to be played is live streams.Returns
int getAgoraCDNLineCount();
Gets the number of CDN routes for the media resource.
Returns
int getCurrentAgoraCDNIndex();
Gets the CDN routes index of the current media resource.
Returns
getAgoraCDNLineCount()
].int switchAgoraCDNLineByIndex(int index);
Changes the CDN route for playing the media resource.
After calling openWithAgoraCDNSrc
to open the media resource, you can call this method if you want to change the CDN routes for playing the media resource.
Note
openWithAgoraCDNSrc
to open the media resource before calling this method.play
, the CDN route is not changed until the playing is completed.Parameter
index
: The index of the CDN routes.Returns
int switchAgoraCDNSrc(String src, boolean syncPts);
Switches the CDN routes for playing the media resource.
API comparison
If you want to switch the CDN routes for playing the media resource, call the switchSrc
method. If you want to choose the CDN route for playing the media resource to improve the viewing experience, you can call the switchAgoraCDNSrc
method, and Agora changes the CDN route for playing accordingly.
Note
openWithAgoraCDNSrc
to open the media resource before calling this method.play
, the CDN route is not changed until the playing is completed.Authentication
If you want to improve the security of the media files to be played, contact support@agora.io to determine the sign
and the ts
field for authentication. To obtain the authenticated URL of the media resource, you need to use these two fields as the query parameters. The following is an example:
rtmp://$domain/$appName/$streamName
rtmp://$domain/$appName/$streamName?ts=$ts&sign=$sign
Authentication information:
sign
: An encrypted string calculated according to the md5 algorithm based on authKey
,appName
,streamName
, and ts
. You need to contact support@agora.io for your authKey.ts
: The timestamp when the authentication information expires. You can set the validity period of the authentication information according to your scenarios, for example, 24 hours or 1h30m20s.Parameters
src
: The URL of the media resource.syncPts
: Whether to synchronize the playback position (ms) before and after the switch:true
: Synchronize the playback position before and after the switch.false
: (Default) Do not synchronize the playback position before and after the media resource switch.Make sure to set syncPts
as false if you need to play live streams, or the switch fails. If you need to play on-demand streams, you can set the value of syncPts
according to your scenarios.
Returns
int renewAgoraCDNSrcToken(String token, long ts);
Renew the authentication information for the URL of the media resource to be played.
When the authentication information expires, you can call the openWithAgoraCDNSrc
to reopen the midia resource or the switchAgoraCDNSrc
method to switch the media resource, and then pass in the authenticated URL (with authentication information updated) of the media resource.
If your authentication information expires when you call the switchAgoraCDNLineByIndex
to switch the CDN route for playing the media resource, you need to call the renewAgoraCDNSrcToken
method to pass in the updated authentication information and call the switchAgoraCDNLineByIndex
to switch the route.
Note
You need to set the value of ts
properly according to your scenarios, or contact support@agora.io for advice.
Parameters
token
: The authentication field. See the sign
field in Authentication information.ts
: The timestamp when the authentication information expires. See the ts
field in Authentication information.Returns
int play();
Plays the media resource.
Note
After open
, pause
, or seek
, you can call this method to play the media resource.
Returns
int pause();
Pauses the playback.
Returns
int stop();
Stops the playback.
Returns
int resume();
Resumes the playback.
Returns
int seek(long newPos);
Seeks to a new playback position.
To play the media file from a specific position, do the following:
Call the seek
method to seek to the position you want to begin playback.
Call the play
method to play the media file.
Parameter
newPos
: The new playback position (ms).Returns
long getDuration();
Gets the duration of the media resource.
Returns
long getPlayPosition();
Gets the current playback progress.
Returns
int getStreamCount();
Gets the number of media streams in the media resource.
Returns
MediaStreamInfo getStreamInfo(int index);
Gets the detailed information of the media stream.
Parameters
index
: The index of the media streams.Returns
MediaStreamInfo
for details.null
.int setPlaybackSpeed(int speed);
Sets the playback speed.
Note
Before you call this method, make sure the media file is opened.
Parameters
speed
: The playback speed. The value ranges from 50 to 400. The default value is 100, meaning the orginal playback speed. 50 means the playback speed is set as 0.50 times the original speed and 400 means 4.00 times the original speed.Returns
int selectAudioTrack(int index);
Selects the audio track used during playback.
Note
Before you call this method, make sure the media file is opened.
Parameter
index
: The index of the audio tracks.Returns
int takeScreenshot(String filename);
Takes screenshots when the video file is being played.
Parameters
filename
: The file name of the screenshot.Returns
int selectInternalSubtitle(int index);
Selects the subtitles added in the video.
Note
Before you call this method, make sure the media file is opened.
Parameter
index
: The index of the added subtitles.Returns
int setExternalSubtitle(String url);
Sets the external subtitles.
Note
setPlayerOption
method and set the key
parameter as "video_decoder_type"
and value
as 1
.Parameter
url
: The URL of external subtitles.Returns
Constants.MediaPlayerState getState();
Gets the current playback state.
Returns
MediaPlayerState
for details.null
.int mute(boolean mute);
Sets whether to mute the media resource.
Parameters
mute
: Sets whether to mute the media resource:true
: Mute the media resource.false
: (Default) Do not mute the media resource.Returns
public synchronized boolean getMute() {
return muted;
}
Confirms whether the media resource is muted.
Returns
true
: The media resource is muted.false
: The media resource is not muted.int adjustPlayoutVolume(int volume);
Adjusts the volume of the playback.
Parameter
volume
: The volume of the playback, which ranges from 0 to 100. If the volume
is set as 100, it means the original volume.Returns
int getPlayoutVolume();
Gets the current volume of the playback.
Return
The current volume of the playback.
int setPlayerOption(String key, int value);
Customizes private options for the media player.
Agora recommends the default options of the SDK. If you need to customize options, contact support@agora.io for details.
Note
Call this method before the open
method.
Parameters
key
: Key.value
: Value.Returns
public synchronized int setView(View videoView) {
if(videoView == null){
return nativeSetView(mediaPlayerNativeHandle, null);
}
if( videoView instanceof SurfaceView){
SurfaceView surfaceView = (SurfaceView) videoView;
final SurfaceHolder surfaceHolder = surfaceView.getHolder();
if(surfaceHolder != null && surfaceHolder.getSurface() != null){
return nativeSetView(mediaPlayerNativeHandle, surfaceHolder.getSurface());
} else if(surfaceHolder != null) {
final SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
nativeSetView(mediaPlayerNativeHandle, holder.getSurface());
surfaceHolder.removeCallback(this);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
};
surfaceHolder.addCallback(callback);
return 0;
}
} else if(videoView instanceof TextureView){
TextureView textureView = (TextureView) videoView;
SurfaceTexture texture = textureView.getSurfaceTexture();
if(texture != null) {
Surface surface = new Surface(texture);
return nativeSetView(mediaPlayerNativeHandle, surface);
} else {
TextureView.SurfaceTextureListener listener = new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Surface surface1 = new Surface(surface);
nativeSetView(mediaPlayerNativeHandle, surface1);
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
}
};
textureView.setSurfaceTextureListener(listener);
return 0;
}
} else {
Log.e(TAG, "setView: invalid view type" );
}
return ERR_INVALID_ARGUMENT;
}
Sets the render view of the player.
Parameters
videoView
: The render view of the player.Returns
int setRenderMode(int mode);
Sets the render mode of the player.
Parameters
mode
: The render mode of the player, see PLAYER_RENDER_MODE_
for details.Returns
int setLoopCount(int loopCount);
Sets the loop playback.
When the loop playback ends, the SDK returns PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED(6)
.
Parameter
loopCount
: The number of times to loop the playback.Returns
int switchSrc(String src, boolean syncPts);
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(11)
, the switch is successful. If you receive the onPlayerEvent
callback event PLAYER_EVENT_SWITCH_ERROR(12)
, the switch fails.
API comparison
If you want to switch the CDN route for playing the media resource, call the switchSrc
method. If you want to choose the CDN route for playing the media resource to improve the viewing experience, you can call the switchAgoraCDNSrc
method, and Agora changes the CDN route for playing accordingly.
Note
open
method.switchSrc(src, true)
:seek
method during switching.Parameters
src
: The URL of the media resource to be switched.syncPts
: Whether to synchronize the playback position (ms) before and after the switch:true
: (Default) Synchronize the playback position before and after the switch.false
: Do not synchronize the playback position before and after the switch.Make sure to set syncPts
as false
if you need to play live streams; otherwise, the switch fails. If you need to play on-demand streams, you can set the value of syncPts
according to your scenarios.
Returns
int preloadSrc(String src, long startPos);
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 preloadSrc
, if you receive the onPreloadEvent
callback event PLAYER_PRELOAD_EVENT_COMPLETE(1)
, the preload is successful. If you receive the onPreloadEvent
callback event PLAYER_PRELOAD_EVENT_ERROR(2)
, the preload fails.
If the preload is successful and you want to play the media resource, call playPreloadedSrc
. If you want to clear the playlist, call the stop
method.
Note
Agora does not support preloading duplicate media resources to the playlist. However, you can preload the media resources that are being played to the playlist again.
Parameters
src
: The URL of the preloaded media resource.startPos
: The starting position (ms) for playing after the media resource is preloaded to the playlist. When preloading a live stream, set startPos
to 0.Returns
int unloadSrc(String src);
Unloads media resources that are preloaded.
Note
The media resource being played cannot be unloaded.
Parameter
src
: The URL of the media resource to be unloaded. Returns
int playPreloadedSrc(String src);
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 which reports 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 the URL of the new media resource that you want to preload. If you want to replay the media resource, you need to call preloadSrc
to preload the media resource to the playlist again before playing. If you want to clear the playlist, call the stop
method.
Note
If you call this method when playback is paused, this method does not take effect until playback is resumed.
Parameter
src
: The URL of the media resource in the playlist. This address must be consistent with the src
set by the preloadSrc
method; otherwise, the media resource cannot be played.Returns
int registerPlayerObserver(IMediaPlayerObserver playerObserver);
Registers a player observer.
Parameters
playerObserver
: The player observer listening for events during the playback. See IMediaPlayerObserver
for details.Returns
int unRegisterPlayerObserver(IMediaPlayerObserver playerObserver);
Unregisters a player observer.
Parameter
playerObserver
: The player observer listening for events during the playback. See IMediaPlayerObserver
for details.Returns
int registerAudioFrameObserver(IMediaPlayerAudioFrameObserver observer);
Registers an audio observer.
Parameters
observer
: The audio observer. See IMediaPlayerAudioFrameObserver
for details.Returns
int unRegisterMediaPlayerAudioFrameObserver(IMediaPlayerAudioFrameObserver observer);
Unregisters an audio observer.
Parameters
observer
: The audio observer. See IMediaPlayerAudioFrameObserver
for details.Returns
int registerVideoFrameObserver(IMediaPlayerVideoFrameObserver observer);
Registers a video observer.
Parameters
observer
: The video observer. See IMediaPlayerVideoFrameObserver
for details.Returns
int unRegisterMediaPlayerVideoFrameObserver(IMediaPlayerVideoFrameObserver observer);
Unregisters a video observer.
Parameters
observer
: The video observer. See IMediaPlayerVideoFrameObserver
for details.Returns
This interface is defined in io.agora.mediaplayer
.
@CalledByNative
void onPlayerStateChanged(Constants.MediaPlayerState state, Constants.MediaPlayerError error);
Reports the change in the playback state.
Parameters
state
: The new playback state after the change. See MediaPlayerState
for details.error
: The error codes of the player. See MediaPlayerError
for details.@CalledByNative void onPositionChanged(long position);
Reports the current playback progress.
The callback occurs every two seconds during the playback and reports the current playback progress.
Parameter
position
: The current playback progress (ms).@CalledByNative
void onPlayerEvent(Constants.MediaPlayerEvent eventCode, long elapsedTime, String message);
Reports playback events.
This callback reports playback events, such as seeking to a new position, selecting the audio track, or changing the bitrate of media resources.
Parameters
eventCode
: The playback event, see MediaPlayerEvent
for details.elapsedTime
: The time when the event occurs (ms).message
: Information about the event.@CalledByNative void onMetaData(Constants.MediaPlayerMetadataType type, byte[] data);
Reports the reception of the media metadata.
Parameters
type
: The type of the media metadata. data
: Data of the media metadata.@CalledByNative void onPlayBufferUpdated(long playCachedBuffer);
Reports the playback duration that the buffered data can support.
When playing online media resources, the mediaplayer kit triggers this callback every two seconds to report the playback duration that the currently buffered data can support.
PLAYER_EVENT_BUFFER_LOW(6)
.PLAYER_EVENT_BUFFER_RECOVER(7)
.Parameter
playCachedBuffer
: The playback duration (ms) that the buffered data can support.@CalledByNative void onPreloadEvent(String src, Constants.MediaPlayerPreloadEvent event);
Reports the events of preloading media resources.
Parameters
src
: The URL of the preloaded media resource.event
: Events that occur when media resources are preloaded, see MediaPlayerPreloadEvent
for details.@CalledByNative void onAgoraCDNTokenWillExpire();
Occurs when the token is to expire.
If your authentication information expires when you call the switchAgoraCDNLineByIndex
to switch the CDN route for playing the media resource, you need to call the renewAgoraCDNSrcToken
method to pass in the updated authentication information and call the switchAgoraCDNLineByIndex
to switch the route.
This interface is defined in io.agora.mediaplayer
.
@CalledByNative void onFrame(MediaPlayerAudioFrame frame)
Occurs each time the player receives an audio frame.
After registering the audio frame observer, the callback occurs every time the player receives an audio frame, reporting the detailed information of the audio frame.
Parameter
audioFrame
: - audioFrame
: Audio frame information. See MediaPlayerAudioFrame
.This interface is defined in io.agora.mediaplayer
.
@CalledByNative void onFrame(MediaPlayerVideoFrame frame)
Occurs each time the player receives a video frame.
After registering the video frame observer, the callback occurs every time the player receives a video frame, reporting the detailed information of the video frame.
Parameter
videoFrame
: Video frame information. See MediaPlayerVideoFrame
for details.This interface is defined in io.agora.mediaplayer
.
int onReadData(ByteBuffer buffer, int bufferSize);
Occurs when the SDK reads the data of the media resource.
When you call openWithCustomSource
to open the media resource, the SDK triggers this callback to request the buffer of the media resource.
Parameters
buffer
: Data butter (bytes), an input parameter. You need to pass in the value of buffer
according to the bufferSize
reported by the SDK.bufferSize
: The size of data buffer (bytes).Returns
0
.long onSeek(long offset, int whence);
Occurs when the SDK seeks to a position of the media resource.
When you call the openWithCustomSource
method to open a custom media resource, the SDK triggers this callback to request the specified location in the media resource.
Parameters
offset
: An input parameter. The offset of the target position relative to the starting point, in bytes. The value can be positive or negative.whence
: An input parameter. The starting point. You can set it as one of the following values:0
: The starting point is the head of the data, and the actual data offset after seeking is offset
.1
: The starting point is the current position, and the actual data offset after seeking is the current position plus offset
.2
: The starting point is the end of the data, and the actual data offset after seeking is the whole data length plus offset
.Returns
seek
.-1
.PLAYER_RENDER_MODE_HIDDEN = 1
Uniformly scales the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
PLAYER_RENDER_MODE_FIT = 2
Uniformly scales the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
ORIGINAL_PLAYBACK_SPEED(100)
The orginal playback speed.
PLAYBACK_SPEED_50_PERCENT(50)
The playback speed is 0.50 times the original speed.
PLAYBACK_SPEED_75_PERCENT(75)
The playback speed is 0.75 times the original speed.
PLAYBACK_SPEED_125_PERCENT(125)
The playback speed is 1.25 times the original speed.
PLAYBACK_SPEED_150_PERCENT(150)
The playback speed is 1.50 times the original speed.
PLAYBACK_SPEED_200_PERCENT(200)
The playback speed is 2.00 times the original speed.
PLAYER_STATE_UNKNOWN(-1)
The player state is unkown.
PLAYER_STATE_IDLE(0)
Default state. The player returns this state code before you open the media resource or after you stop the playback.
PLAYER_STATE_OPENING(1)
The player is opening the media resource.
PLAYER_STATE_OPEN_COMPLETED(2)
The player opened the media resource successfully.
PLAYER_STATE_PLAYING(3)
The player is playing the media resource.
PLAYER_STATE_PAUSED(4)
The playback is paused.
PLAYER_STATE_PLAYBACK_COMPLETED(5)
The playback is completed.
PLAYER_STATE_PLAYBACK_ALL_LOOPS_COMPLETED(6)
The loop playback is completed.
PLAYER_STATE_STOPPED(7)
The playback finishes.
PLAYER_STATE_PAUSING_INTERNAL(50)
The player is pausing.
PLAYER_STATE_STOPPING_INTERNAL(51)
The player is stopping.
PLAYER_STATE_SEEKING_INTERNAL(52)
The player is seeking the playback position of the media resource.
PLAYER_STATE_GETTING_INTERNAL(53)
The player is getting the media resource.
PLAYER_STATE_NONE_INTERNAL(54)
No state.
PLAYER_STATE_DO_NOTHING_INTERNAL(55)
The player is idle.
PLAYER_STATE_SET_TRACK_INTERNAL(56)
The player is setting the track of the media resource.
PLAYER_STATE_FAILED(100)
The player fails to play the media resource.
PLAYER_ERROR_NONE(0)
No error.
PLAYER_ERROR_INVALID_ARGUMENTS(-1)
Invalid arguments.
PLAYER_ERROR_INTERNAL(-2)
Internal error.
PLAYER_ERROR_NO_RESOURCE(-3)
No resource.
PLAYER_ERROR_INVALID_MEDIA_SOURCE(-4)
Invalid media resource.
PLAYER_ERROR_UNKNOWN_STREAM_TYPE(-5)
The type of the media stream is unknown.
PLAYER_ERROR_OBJ_NOT_INITIALIZED(-6)
The object is not initialized.
PLAYER_ERROR_CODEC_NOT_SUPPORTED(-7)
The codec is not supported.
PLAYER_ERROR_VIDEO_RENDER_FAILED(-8)
Invalid renderer.
PLAYER_ERROR_INVALID_STATE(-9)
Errors occur in the internal state of the player.
PLAYER_ERROR_URL_NOT_FOUND(-10)
The URL of the media resource cannot be found.
PLAYER_ERROR_INVALID_CONNECTION_STATE(-11)
Invalid connection between the player and the Agora Server.
PLAY_ERROR_SRC_BUFFER_UNDERFLOW(-12)
The playback buffer is insufficient.
PLAYER_ERROR_INTERRUPTED(-13)
The playback is interrupted.
PLAYER_ERROR_NOT_SUPPORTED(-14)
The SDK does not support the method being called.
PLAYER_ERROR_TOKEN_EXPIRED(-15)
The authentication information of the media resource is expired. To update the authentication information, see renewAgoraCDNSrcToken
.
PLAYER_ERROR_IP_EXPIRED(-16)
The IP information is expired.
PLAYER_ERROR_UNKNOWN(-17)
An unknown error.
PLAYER_EVENT_UNKNOWN(-1)
An unknown event.
PLAYER_EVENT_SEEK_BEGIN(0)
The player begins to seek to a new playback position.
PLAYER_EVENT_SEEK_COMPLETE(1)
The player finishes seeking to a new playback position.
PLAYER_EVENT_SEEK_ERROR(2)
An error occurs when seeking to a new playback position.
PLAYER_EVENT_AUDIO_TRACK_CHANGED(5)
The audio track used by the player has been changed.
PLAYER_EVENT_BUFFER_LOW(6)
The currently buffered data is not sufficient to support playback.
PLAYER_EVENT_BUFFER_RECOVER(7)
The currently buffered data is just enough to support playback.
PLAYER_EVENT_FREEZE_START(8)
The audio or video playback freezes.
PLAYER_EVENT_FREEZE_STOP(9)
The audio or video playback resumes without freezing.
PLAYER_EVENT_SWITCH_BEGIN(10)
The player starts switching the media resource.
PLAYER_EVENT_SWITCH_COMPLETE(11)
Media resource switching is complete.
PLAYER_EVENT_SWITCH_ERROR(12)
Media resource switching error.
PLAYER_EVENT_FIRST_DISPLAYED(13)
The first video frame is rendered.
PLAYER_EVENT_REACH_CACHE_FILE_MAX_COUNT(14)
The limit of the number of cached media files is reached.
PLAYER_EVENT_REACH_CACHE_FILE_MAX_SIZE(15)
The aggregate storage space limit is reached.
PLAYER_EVENT_TRY_OPEN_START(16)
Triggered when a retry is required to open the media resource.
PLAYER_EVENT_TRY_OPEN_SUCCEED(17)
Triggered when the retry to open the media resource succeeds.
PLAYER_EVENT_TRY_OPEN_FAILED(18)
Triggered when the retry to open the media resource fails.
PLAYER_PRELOAD_EVENT_BEGIN(0)
Starts preloading media resources.
PLAYER_PRELOAD_EVENT_COMPLETE(1)
Preloading media resources is complete.
PLAYER_PRELOAD_EVENT_ERROR(2)
An error occurs when preloading media resources.
STREAM_TYPE_UNKNOWN(0)
The type is unknown.
STREAM_TYPE_VIDEO(1)
The video stream.
STREAM_TYPE_AUDIO(2)
The audio stream.
STREAM_TYPE_SUBTITLE(3)
The subtitle stream.
PLAYER_METADATA_TYPE_UNKNOWN(0)
The type is unknown.
PLAYER_METADATA_TYPE_SEI(1)
The type is SEI.
The MediaStreamInfo
is defined in io.agora.mediaplayer.data
.
private int streamIndex
The index of the media stream.
private int mediaStreamType
The type of the media stream. See MediaStreamType
for details.
private String codecName
The codec of the media stream.
private String language
The language of the media stream.
private int videoFrameRate
For a video stream, gets the frame rate (fps).
private int videoBitRate
For a video stream, gets the bitrate (bps).
private int videoWidth
For a video stream, gets the width (px) of the video.
private int videoHeight
For a video stream, gets the height (px) of the video.
private int audioSampleRate
For an audio stream, gets the sample rate (Hz).
private int audioChannels
For an audio stream, gets the number of audio channels.
private long duration
The total duration (s) of the media stream.
private int videoRotation
For a video stream, gets the rotation angle of the video.
The MediaPlayerAudioFrame
is defined in io.agora.mediaplayer.data
.
private long timestamp
The timestamp (ms) of the current audio frame.
private long samplesPerChannel
The number of samples per channel.
private int sampleRateHz
The sample rate (Hz) of the audio data.
private int numChannels
The channel number of an audio stream.
private int bytesPerSample
The number of bytes per sample.
ByteBuffer buffer
The playback buffer.
typMediaPlayerVideoFrame
is defined in io.agora.mediaplayer.data
.
int type
The video format.
int width
The width (px) of the video.
int height
The height (px) of the video.
int yStride
For YUV data, the line span of the Y buffer; for RGBA data, the total data length.
int uStride
For YUV data, the line span of the U buffer; for RGBA data, the value is 0.
int vStride
For YUV data, the line span of the V buffer; for RGBA data, the value is 0.
ByteBuffer yBuffer
For YUV data, the pointer to the Y buffer; for RGBA data, the data buffer.
ByteBuffer uBuffer
For YUV data, the pointer to the U buffer; for RGBA data, the value is 0.
ByteBuffer vBuffer
For YUV data, the pointer to the V buffer; for RGBA data, the value is 0.
int rotation
The clockwise rotation angle of the video frame. The supported values are 0, 90, 180, or 270 degrees.
long renderTimeMs
The Unix timestamp (ms) when the video frame is rendered. This timestamp can be used to guide the rendering of the video frame. This parameter is required.
int avsyncType
Reserved parameter.
String metadataBuffer
The metadata Buffer.