io.agora.rtc

## Class AgoraMediaPlayerSource

- java.lang.Object
- - io.agora.rtc.AgoraMediaPlayerSource

-     public class AgoraMediaPlayerSource
      extends java.lang.Object

  Wrapper for media player source functionality.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private IAgoraMediaPlayerSourceObserver` | `_AgoraMediaPlayerSourceObserver` Observer for media player source events
    `private IAudioFrameObserver` | `_AudioFrameObserver` Observer for audio frame events
    `private long` | `cptr` Native pointer to the media player source instance.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraMediaPlayerSource(long cptr)` Constructs a media player source.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()` Destroys the media player source and releases native resources.
    `void` | `destroyStreamInfo(MediaStreamInfo info)` Destroys a stream info object.
    `long` | `getDuration()` Gets the total duration of the media.
    `long` | `getPlayPosition()` Gets the current playback position.
    `int` | `getSourceId()` Gets the source ID of the media player.
    `int` | `getState()` Gets the current playback state.
    `long` | `getStreamCount()` Gets the number of media streams.
    `MediaStreamInfo` | `getStreamInfo(long index)` Gets information about a specific stream.
    `private void` | `ndestroy()` Destroys the native media player source.
    `int` | `open(java.lang.String url, long start_pos)` Opens a media file or URL for playback.
    `int` | `pause()` Pauses playback.
    `int` | `play()` Starts playback.
    `int` | `registerAudioFrameObserver(IAudioFrameObserver observer)` Registers an audio frame observer.
    `int` | `registerPlayerSourceObserver(IAgoraMediaPlayerSourceObserver observer)` Registers a player source observer.
    `int` | `resume()` Resumes playback.
    `int` | `seek(long new_pos)` Seeks to a specific position.
    `int` | `selectAudioTrack(int index)` Selects an audio track.
    `int` | `selectInternalSubtitle(int index)` Selects an internal subtitle track.
    `int` | `setExternalSubtitle(java.lang.String url)` Sets an external subtitle file.
    `int` | `setLoopCount(int loop_count)` Sets the loop count for playback.
    `int` | `setPlayerOption(java.lang.String key, int value)` Sets a player option.
    `int` | `stop()` Stops playback.
    `int` | `takeScreenshot(java.lang.String filename)` Takes a screenshot of the current frame.
    `int` | `unregisterAudioFrameObserver(IAudioFrameObserver observer)` Unregisters an audio frame observer.
    `int` | `unregisterPlayerSourceObserver(IAgoraMediaPlayerSourceObserver observer)` Unregisters a player source observer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cptr

          private long cptr

      Native pointer to the media player source instance.

    - #### _AgoraMediaPlayerSourceObserver

          private IAgoraMediaPlayerSourceObserver _AgoraMediaPlayerSourceObserver

      Observer for media player source events

    - #### _AudioFrameObserver

          private IAudioFrameObserver _AudioFrameObserver

      Observer for audio frame events

  - ### Constructor Detail

    - #### AgoraMediaPlayerSource

          public AgoraMediaPlayerSource(long cptr)

      Constructs a media player source.
      Parameters:
        `cptr` - Native pointer to the player source instance

  - ### Method Detail

    - #### ndestroy

          private void ndestroy()

      Destroys the native media player source.

    - #### destroy

          public void destroy()

      Destroys the media player source and releases native resources.

    - #### getSourceId

          public int getSourceId()

      Gets the source ID of the media player.
      Returns:
        Source ID

    - #### open

          public int open(java.lang.String url,
                          long start_pos)

      Opens a media file or URL for playback.
      Parameters:
        `url` - Media file path or URL
        `start_pos` - Starting position in milliseconds
      Returns:
        0 on success, <0 on failure

    - #### play

          public int play()

      Starts playback.
      Returns:
        0 on success, <0 on failure

    - #### pause

          public int pause()

      Pauses playback.
      Returns:
        0 on success, <0 on failure

    - #### stop

          public int stop()

      Stops playback.
      Returns:
        0 on success, <0 on failure

    - #### resume

          public int resume()

      Resumes playback.
      Returns:
        0 on success, <0 on failure

    - #### seek

          public int seek(long new_pos)

      Seeks to a specific position.
      Parameters:
        `new_pos` - New position in milliseconds
      Returns:
        0 on success, <0 on failure

    - #### getDuration

          public long getDuration()

      Gets the total duration of the media.
      Returns:
        Duration in milliseconds

    - #### getPlayPosition

          public long getPlayPosition()

      Gets the current playback position.
      Returns:
        Current position in milliseconds

    - #### getStreamCount

          public long getStreamCount()

      Gets the number of media streams.
      Returns:
        Number of streams

    - #### getStreamInfo

          public MediaStreamInfo getStreamInfo(long index)

      Gets information about a specific stream.
      Parameters:
        `index` - Stream index
      Returns:
        Stream information

    - #### destroyStreamInfo

          public void destroyStreamInfo(MediaStreamInfo info)

      Destroys a stream info object.
      Parameters:
        `info` - Stream info object to destroy

    - #### setLoopCount

          public int setLoopCount(int loop_count)

      Sets the loop count for playback.
      Parameters:
        `loop_count` - Number of times to loop
      Returns:
        0 on success, <0 on failure

    - #### selectAudioTrack

          public int selectAudioTrack(int index)

      Selects an audio track.
      Parameters:
        `index` - Audio track index
      Returns:
        0 on success, <0 on failure

    - #### setPlayerOption

          public int setPlayerOption(java.lang.String key,
                                     int value)

      Sets a player option.
      Parameters:
        `key` - Option key
        `value` - Option value
      Returns:
        0 on success, <0 on failure

    - #### takeScreenshot

          public int takeScreenshot(java.lang.String filename)

      Takes a screenshot of the current frame.
      Parameters:
        `filename` - Output filename for the screenshot
      Returns:
        0 on success, <0 on failure

    - #### selectInternalSubtitle

          public int selectInternalSubtitle(int index)

      Selects an internal subtitle track.
      Parameters:
        `index` - Subtitle track index
      Returns:
        0 on success, <0 on failure

    - #### setExternalSubtitle

          public int setExternalSubtitle(java.lang.String url)

      Sets an external subtitle file.
      Parameters:
        `url` - URL or path to the subtitle file
      Returns:
        0 on success, <0 on failure

    - #### getState

          public int getState()

      Gets the current playback state.
      Returns:
        Playback state

    - #### registerPlayerSourceObserver

          public int registerPlayerSourceObserver(IAgoraMediaPlayerSourceObserver observer)

      Registers a player source observer.
      Parameters:
        `observer` - Observer instance
      Returns:
        0 on success, <0 on failure

    - #### unregisterPlayerSourceObserver

          public int unregisterPlayerSourceObserver(IAgoraMediaPlayerSourceObserver observer)

      Unregisters a player source observer.
      Parameters:
        `observer` - Observer instance
      Returns:
        0 on success, <0 on failure

    - #### registerAudioFrameObserver

          public int registerAudioFrameObserver(IAudioFrameObserver observer)

      Registers an audio frame observer.
      Parameters:
        `observer` - Observer instance
      Returns:
        0 on success, <0 on failure

    - #### unregisterAudioFrameObserver

          public int unregisterAudioFrameObserver(IAudioFrameObserver observer)

      Unregisters an audio frame observer.
      Parameters:
        `observer` - Observer instance
      Returns:
        0 on success, <0 on failure