Agora C++ API Reference for All Platforms
Public Member Functions | Protected Member Functions | List of all members
agora::rtc::IMediaPlayerSource Class Referenceabstract

Inherits agora::RefCountInterface.

Inherited by agora::rtc::IMediaPlayerSourceEx.

Public Member Functions

virtual int getSourceId () const =0
 
virtual int open (const char *url, int64_t startPos)=0
 
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 changePlaybackSpeed (media::base::MEDIA_PLAYER_PLAYBACK_SPEED 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
 
- Public Member Functions inherited from agora::RefCountInterface
virtual void AddRef () const =0
 
virtual RefCountReleaseStatus Release () const =0
 
virtual bool HasOneRef () const =0
 

Protected Member Functions

virtual ~IMediaPlayerSource ()
 
- Protected Member Functions inherited from agora::RefCountInterface
virtual ~RefCountInterface ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ~IMediaPlayerSource()

virtual agora::rtc::IMediaPlayerSource::~IMediaPlayerSource ( )
inlineprotectedvirtual

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.

◆ 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

◆ changePlaybackSpeed()

virtual int agora::rtc::IMediaPlayerSource::changePlaybackSpeed ( media::base::MEDIA_PLAYER_PLAYBACK_SPEED  speed)
pure virtual

Changes the playback speed.

Parameters
speedThe playback speed. See MEDIA_PLAYER_PLAYBACK_SPEED for details.
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