Agora Java API Reference for Android
Public Member Functions | List of all members
agora::rtc::IMediaPlayerSource Class Referenceabstract

#include <IAgoraMediaPlayerSource.h>

Inheritance diagram for agora::rtc::IMediaPlayerSource:
agora::RefCountInterface

Public Member Functions

virtual int getSourceId () const =0
 
virtual int open (const char *url, int64_t startPos)=0
 
virtual int openWithCustomSource (int64_t startPos, IMediaPlayerCustomDataProvider *provider)=0
 Open media file or stream with custom soucrce. More...
 
virtual int play ()=0
 
virtual int pause ()=0
 
virtual int stop ()=0
 
virtual int resume ()=0
 
virtual int seek (int64_t newPos)=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::PlayerStreamInfo *info)=0
 
virtual int setLoopCount (int64_t loopCount)=0
 
virtual int muteAudio (bool audio_mute)=0
 
virtual bool isAudioMuted ()=0
 
virtual int muteVideo (bool audio_mute)=0
 
virtual bool isVideoMuted ()=0
 
virtual int setPlaybackSpeed (int speed)=0
 
virtual int selectAudioTrack (int64_t index)=0
 
virtual int setPlayerOption (const char *key, int64_t value)=0
 
virtual int setPlayerOption (const char *key, const char *value)=0
 
virtual int takeScreenshot (const char *filename)=0
 
virtual int selectInternalSubtitle (int64_t index)=0
 
virtual int setExternalSubtitle (const char *url)=0
 
virtual media::base::MEDIA_PLAYER_STATE getState ()=0
 
virtual int registerPlayerSourceObserver (IMediaPlayerSourceObserver *observer)=0
 
virtual int unregisterPlayerSourceObserver (IMediaPlayerSourceObserver *observer)=0
 
virtual int registerAudioFrameObserver (media::base::IAudioFrameObserver *observer)=0
 
virtual int unregisterAudioFrameObserver (media::base::IAudioFrameObserver *observer)=0
 
virtual int openWithAgoraCDNSrc (const char *src, int64_t startPos)=0
 
virtual int getAgoraCDNLineCount ()=0
 
virtual int switchAgoraCDNLineByIndex (int index)=0
 
virtual int getCurrentAgoraCDNIndex ()=0
 
virtual int enableAutoSwitchAgoraCDN (bool enable)=0
 
virtual int renewAgoraCDNSrcToken (const char *token, int64_t ts)=0
 
virtual int switchAgoraCDNSrc (const char *src, bool syncPts=false)=0
 
virtual int switchSrc (const char *src, bool syncPts)=0
 
virtual int preloadSrc (const char *src, int64_t startPos)=0
 
virtual int unloadSrc (const char *src)=0
 
virtual int playPreloadedSrc (const char *src)=0
 
- Public Member Functions inherited from agora::RefCountInterface
virtual void AddRef () const =0
 
virtual RefCountReleaseStatus Release () const =0
 
virtual bool HasOneRef () const =0
 

Detailed Description

The IMediaPlayerSource class provides access to a media player source. To playout multiple media sources simultaneously, create multiple media player source objects.

Member Function Documentation

◆ getSourceId()

virtual int agora::rtc::IMediaPlayerSource::getSourceId ( ) const
pure virtual

Gets the unique source ID of the media player source.

Returns
  • >=0: The source ID of this media player source.
  • < 0: Failure.

◆ open()

virtual int agora::rtc::IMediaPlayerSource::open ( const char *  url,
int64_t  startPos 
)
pure virtual

Opens a media file with a specified URL.

Parameters
urlThe path of the media file. Both the local path and online path are supported.
startPosThe starting position (ms) for playback. Default value is 0.
Returns
  • 0: Success.
  • < 0: Failure.

◆ openWithCustomSource()

virtual int agora::rtc::IMediaPlayerSource::openWithCustomSource ( int64_t  startPos,
IMediaPlayerCustomDataProvider provider 
)
pure virtual

Open media file or stream with custom soucrce.

Parameters
startPosSet the starting position for playback, in seconds
observerdataProvider object
Returns
  • 0: Success.
  • < 0: Failure.

◆ play()

virtual int agora::rtc::IMediaPlayerSource::play ( )
pure virtual

Plays the media file.

Returns
  • 0: Success.
  • < 0: Failure.

◆ pause()

virtual int agora::rtc::IMediaPlayerSource::pause ( )
pure virtual

Pauses the playback.

Returns
  • 0: Success.
  • < 0: Failure.

◆ stop()

virtual int agora::rtc::IMediaPlayerSource::stop ( )
pure virtual

Stops the playback.

Returns
  • 0: Success.
  • < 0: Failure.

◆ resume()

virtual int agora::rtc::IMediaPlayerSource::resume ( )
pure virtual

Resumes the playback.

Returns
  • 0: Success.
  • < 0: Failure.

◆ seek()

virtual int agora::rtc::IMediaPlayerSource::seek ( int64_t  newPos)
pure virtual

Sets the playback position of the media file.

Parameters
newPosThe new playback position (ms).
Returns
  • 0: Success.
  • < 0: Failure.

◆ getDuration()

virtual int agora::rtc::IMediaPlayerSource::getDuration ( int64_t &  duration)
pure virtual

Gets the duration of the media file.

Parameters
[out]durationA reference to the duration of the media file.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getPlayPosition()

virtual int agora::rtc::IMediaPlayerSource::getPlayPosition ( int64_t &  pos)
pure virtual

Gets the current playback position of the media file.

Parameters
[out]posA reference to the current playback position (ms).
Returns

◆ getStreamCount()

virtual int agora::rtc::IMediaPlayerSource::getStreamCount ( int64_t &  count)
pure virtual

Gets the number of the media streams in the media source.

Parameters
[out]countThe number of the media streams in the media source.
Returns

◆ getStreamInfo()

virtual int agora::rtc::IMediaPlayerSource::getStreamInfo ( int64_t  index,
media::base::PlayerStreamInfo info 
)
pure virtual

Gets the detailed information of a media stream.

Parameters
indexThe index of the media stream.
[out]infoThe detailed information of the media stream. See PlayerStreamInfo for details.
Returns

◆ setLoopCount()

virtual int agora::rtc::IMediaPlayerSource::setLoopCount ( int64_t  loopCount)
pure virtual

Sets whether to loop the media file for playback.

Parameters
loopCountThe number of times of looping the media file.
  • 0: Play the media file once.
  • 1: Play the media file twice.
  • -1: Play the media file in a loop indefinitely, until stop is called.
Returns

◆ muteAudio()

virtual int agora::rtc::IMediaPlayerSource::muteAudio ( bool  audio_mute)
pure virtual

Mute the audio playing

Parameters
audio_mute: mute or unmute audio
Returns
  • 0: Success.
  • < 0: Failure.

◆ isAudioMuted()

virtual bool agora::rtc::IMediaPlayerSource::isAudioMuted ( )
pure virtual

Gets whehter audio is muted

Parameters
None
Returns
true or false

◆ muteVideo()

virtual int agora::rtc::IMediaPlayerSource::muteVideo ( bool  audio_mute)
pure virtual

Mute the audio playing

Parameters
audio_mute: mute or unmute audio
Returns
  • 0: Success.
  • < 0: Failure.

◆ isVideoMuted()

virtual bool agora::rtc::IMediaPlayerSource::isVideoMuted ( )
pure virtual

Gets whehter audio is muted

Parameters
None
Returns
true or false

◆ setPlaybackSpeed()

virtual int agora::rtc::IMediaPlayerSource::setPlaybackSpeed ( int  speed)
pure virtual

Changes the playback speed.

Parameters
speedThe playback speed ref [50-400].
Returns

◆ selectAudioTrack()

virtual int agora::rtc::IMediaPlayerSource::selectAudioTrack ( int64_t  index)
pure virtual

Selects an audio track of the media file for playback.

Parameters
indexThe index of the audio track in media file.
Returns

◆ setPlayerOption() [1/2]

virtual int agora::rtc::IMediaPlayerSource::setPlayerOption ( const char *  key,
int64_t  value 
)
pure virtual

Changes the player option before playing a file.

Parameters
keyThe key of the option paramemter.
valueThe value of option parameter.
Returns

◆ setPlayerOption() [2/2]

virtual int agora::rtc::IMediaPlayerSource::setPlayerOption ( const char *  key,
const char *  value 
)
pure virtual

Changes the player option before playing a file.

Parameters
keyThe key of the option paramemter.
valueThe value of option parameter.
Returns

◆ takeScreenshot()

virtual int agora::rtc::IMediaPlayerSource::takeScreenshot ( const char *  filename)
pure virtual

Takes a screenshot when playing a video file.

Parameters
filenameThe filename of the screenshot file.
Returns

◆ selectInternalSubtitle()

virtual int agora::rtc::IMediaPlayerSource::selectInternalSubtitle ( int64_t  index)
pure virtual

Selects internal subtitles for a video file.

Parameters
indexThe index of the internal subtitles.
Returns

◆ setExternalSubtitle()

virtual int agora::rtc::IMediaPlayerSource::setExternalSubtitle ( const char *  url)
pure virtual

Sets an external subtitle file for a video file.

Parameters
urlThe URL of the subtitle file.
Returns

◆ getState()

virtual media::base::MEDIA_PLAYER_STATE agora::rtc::IMediaPlayerSource::getState ( )
pure virtual

Gets the playback state.

Returns
The current playback state. See MEDIA_PLAYER_STATE for details.

◆ registerPlayerSourceObserver()

virtual int agora::rtc::IMediaPlayerSource::registerPlayerSourceObserver ( IMediaPlayerSourceObserver observer)
pure virtual

Registers a media player source observer.

Once the media player source observer is registered, you can use the observer to monitor the state change of the media player.

Parameters
observerThe pointer to the IMediaPlayerSourceObserver object.
Returns

◆ unregisterPlayerSourceObserver()

virtual int agora::rtc::IMediaPlayerSource::unregisterPlayerSourceObserver ( IMediaPlayerSourceObserver observer)
pure virtual

Releases the media player source observer.

Parameters
observerThe pointer to the IMediaPlayerSourceObserver object.
Returns

◆ registerAudioFrameObserver()

virtual int agora::rtc::IMediaPlayerSource::registerAudioFrameObserver ( media::base::IAudioFrameObserver observer)
pure virtual

Registers the audio frame observer.

Parameters
observerThe pointer to the IAudioFrameObserver object.
Returns

◆ unregisterAudioFrameObserver()

virtual int agora::rtc::IMediaPlayerSource::unregisterAudioFrameObserver ( media::base::IAudioFrameObserver observer)
pure virtual

Releases the audio frame observer.

Parameters
observerThe pointer to the IAudioFrameObserver object.
Returns

◆ openWithAgoraCDNSrc()

virtual int agora::rtc::IMediaPlayerSource::openWithAgoraCDNSrc ( const char *  src,
int64_t  startPos 
)
pure virtual

Open the Agora CDN media source.

Parameters
srcThe src of the media file that you want to play.
startPosThe playback position (ms).
Returns
  • 0: Success.
  • < 0: Failure.

◆ getAgoraCDNLineCount()

virtual int agora::rtc::IMediaPlayerSource::getAgoraCDNLineCount ( )
pure virtual

Gets the number of Agora CDN lines.

Returns
  • > 0: number of CDN.
  • <= 0: Failure.

◆ switchAgoraCDNLineByIndex()

virtual int agora::rtc::IMediaPlayerSource::switchAgoraCDNLineByIndex ( int  index)
pure virtual

Switch Agora CDN lines.

Parameters
indexSpecific CDN line index.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getCurrentAgoraCDNIndex()

virtual int agora::rtc::IMediaPlayerSource::getCurrentAgoraCDNIndex ( )
pure virtual

Gets the line of the current CDN.

Returns
  • >= 0: Specific line.
  • < 0: Failure.

◆ enableAutoSwitchAgoraCDN()

virtual int agora::rtc::IMediaPlayerSource::enableAutoSwitchAgoraCDN ( bool  enable)
pure virtual

Enable automatic CDN line switching.

Parameters
enableWhether enable.
Returns
  • 0: Success.
  • < 0: Failure.

◆ renewAgoraCDNSrcToken()

virtual int agora::rtc::IMediaPlayerSource::renewAgoraCDNSrcToken ( const char *  token,
int64_t  ts 
)
pure virtual

Update the CDN source token and timestamp.

Parameters
tokentoken.
tsts.
Returns
  • 0: Success.
  • < 0: Failure.

◆ switchAgoraCDNSrc()

virtual int agora::rtc::IMediaPlayerSource::switchAgoraCDNSrc ( const char *  src,
bool  syncPts = false 
)
pure virtual

Switch the CDN source when open a media through "openWithAgoraCDNSrc" API

Parameters
srcSpecific src.
syncPtsLive streaming must be set to false.
Returns
  • 0: Success.
  • < 0: Failure.

◆ switchSrc()

virtual int agora::rtc::IMediaPlayerSource::switchSrc ( const char *  src,
bool  syncPts 
)
pure virtual

Switch the media source when open a media through "open" API

Parameters
srcSpecific src.
syncPtsLive streaming must be set to false.
Returns
  • 0: Success.
  • < 0: Failure.

◆ preloadSrc()

virtual int agora::rtc::IMediaPlayerSource::preloadSrc ( const char *  src,
int64_t  startPos 
)
pure virtual

Preload a media source

Parameters
srcSpecific src.
startPosThe starting position (ms) for playback. Default value is 0.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unloadSrc()

virtual int agora::rtc::IMediaPlayerSource::unloadSrc ( const char *  src)
pure virtual

Unload a preloaded media source

Parameters
srcSpecific src.
Returns
  • 0: Success.
  • < 0: Failure.

◆ playPreloadedSrc()

virtual int agora::rtc::IMediaPlayerSource::playPreloadedSrc ( const char *  src)
pure virtual

Play a pre-loaded media source

Parameters
srcSpecific src.
Returns
  • 0: Success.
  • < 0: Failure.