Media Player Kit v1.3.0 API Reference for Windows
Public Member Functions | Protected Member Functions | List of all members
agora::rtc::IMediaPlayerSource Class Referenceabstract

Inherits RefCountInterface.

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::MediaStreamInfo *info)=0
 
virtual int setLoopCount (int loopCount)=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 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
 

Protected Member Functions

virtual ~IMediaPlayerSource ()=default
 

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 ( )
protectedvirtualdefault

Member Function Documentation

◆ getSourceId()

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

Get 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 the media resource.

Parameters
srcThe path of the media resource. Both local path and online path are supported.
startPosThe starting position (ms) for playback. Default value is 0.
Returns

◆ play()

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

Plays the media resource.

After open() or pause() or seek(), you can call this method to play the media resource.

Returns

◆ pause()

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

Pauses the playback.

To resume the playback, call the play() method.

Returns

◆ stop()

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

Stops the playback.

Returns

◆ resume()

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

Resumes the playback.

Returns

◆ seek()

virtual int agora::rtc::IMediaPlayerSource::seek ( int64_t  newPos)
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.

Parameters
posThe new playback position (ms).
Returns

◆ getDuration()

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

Gets the duration of the media resource.

Parameters
[out]durationThe total duration (ms) of the media resource.
Returns

◆ getPlayPosition()

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

Gets current playback progress.

Parameters
[out]posThe playback progress (ms).
Returns

◆ getStreamCount()

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

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

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

◆ getStreamInfo()

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

Gets the detailed information of the media stream.

Parameters
indexThe index of the media stream.
[out]infoThe detailed information of the media stream. See MediaStreamInfo for details.
Returns
  • 0: Success.
  • < 0: Failure. See MEDIA_PLAYER_ERROR for details.

◆ setLoopCount()

virtual int agora::rtc::IMediaPlayerSource::setLoopCount ( int  loopCount)
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.

Parameters
loopCountThe number of the loops.
Returns

◆ changePlaybackSpeed()

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

Adjusts the playback speed.

Call this method after the play() method.

Parameters
speedThe playback speed. See MEDIA_PLAYER_PLAYBACK_SPEED for details
Returns

◆ selectAudioTrack()

virtual int agora::rtc::IMediaPlayerSource::selectAudioTrack ( int  index)
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.

Parameters
indexThe index of the audio track.
Returns

◆ setPlayerOption() [1/2]

virtual int agora::rtc::IMediaPlayerSource::setPlayerOption ( const char *  key,
int  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.

Note
Calling this method before the open method.
Parameters
keykey.
valuevalue.
Returns

◆ setPlayerOption() [2/2]

virtual int agora::rtc::IMediaPlayerSource::setPlayerOption ( const char *  key,
const char *  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.

Note
Calling this method before the open method.
Parameters
keykey.
valuevalue.
Returns

◆ setExternalSubtitle()

virtual int agora::rtc::IMediaPlayerSource::setExternalSubtitle ( const char *  url)
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.

Parameters
urlThe URL address of the external subtitle. Both SRT subtitle and ASS subtitle, local address and online address are supported.
Returns

◆ getState()

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

Gets current playback state.

Returns
The current playback state.

◆ 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
  • 0: Success.
  • < 0: Failure.

◆ 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
  • 0: Success.
  • < 0: Failure.

◆ registerAudioFrameObserver()

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

Registers an audio observer.

Parameters
observerThe audio observer, reporting the reception of each audio frame. See IAudioFrameObserver for details.
Returns

◆ unregisterAudioFrameObserver()

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

Unregisters an audio observer.

Parameters
observerThe audio observer, reporting the reception of each audio frame. See IAudioFrameObserver for details.
Returns