|
Agora Java API Reference for Android
|
Classes | |
| enum | MusicPlayMode |
| Playback modes for music resources. More... | |
Public Member Functions | |
| int | open (long songCode, long startPos) |
| Opens a music resource by its resource ID. More... | |
| int | open (String url, long startPos) |
| Opens a music resource via URL. More... | |
| int | destroy () |
| Destroys the music player. More... | |
| String | getPlaySrc () |
| Gets the identifier or URL of the currently playing music resource. More... | |
| int | stop () |
| Stops playing the music resource. More... | |
| int | setPlayMode (MusicPlayMode mode) |
| Sets the playback mode for a music track. More... | |
Public Member Functions inherited from io.agora.mediaplayer.IMediaPlayer | |
| int | getMediaPlayerId () |
| Gets the ID of the media player. More... | |
| int | open (Uri uri, long startPos) |
| Opens a media file through a URI address. More... | |
| int | openWithMediaSource (MediaPlayerSource source) |
| Opens a media file and configures the playback scenarios. More... | |
| int | play () |
| Plays the media file. More... | |
| int | pause () |
| Pauses the playback. More... | |
| int | resume () |
| Resumes playing the media file. More... | |
| int | seek (long newPos) |
| Seeks to a new playback position. More... | |
| int | setAudioPitch (int pitch) |
| Sets the pitch of the current media resource. More... | |
| int | mute (boolean muted) |
| Sets whether to mute the media file. More... | |
| boolean | getMute () |
| Reports whether the media resource is muted. More... | |
| int | adjustPlayoutVolume (int volume) |
| Adjusts the local playback volume. More... | |
| int | getPlayoutVolume () |
| Gets the local playback volume. More... | |
| long | getPlayPosition () |
| Gets current local playback progress. More... | |
| long | getDuration () |
| Gets the duration of the media resource. More... | |
| int | getAudioBufferDelay () |
| Gets the audio buffer delay when playing the media file. More... | |
| Constants.MediaPlayerState | getState () |
| Gets current playback state. More... | |
| int | getStreamCount () |
| Gets the number of the media streams in the media resource. More... | |
| int | setView (View videoView) |
| Sets the view. More... | |
| int | setRenderMode (int mode) |
| Sets the render mode of the media player. More... | |
| MediaStreamInfo | getStreamInfo (int index) |
| Gets the detailed information of the media stream. More... | |
| int | setLoopCount (int loopCount) |
| Sets the loop playback. More... | |
| int | setPlaybackSpeed (int speed) |
| Sets the channel mode of the current audio file. More... | |
| int | selectAudioTrack (int index) |
| Selects the audio track used during playback. More... | |
| int | selectMultiAudioTrack (int playoutTrackIndex, int publishTrackIndex) |
| Selects the audio tracks that you want to play on your local device and publish to the channel respectively. More... | |
| int | setPlayerOption (String key, int value) |
| Sets media player options. More... | |
| int | setPlayerOptionString (String key, String value) |
| Sets media player options. More... | |
| int | takeScreenshot (String filename) |
| int | selectInternalSubtitle (int index) |
| int | setExternalSubtitle (String url) |
| int | adjustPublishSignalVolume (int volume) |
| Adjusts the volume of the media file for publishing. More... | |
| int | getPublishSignalVolume () |
| Gets the volume of the media file for publishing. More... | |
| int | switchSrc (String src, boolean syncPts) |
| Switches the media resource being played. More... | |
| int | preloadSrc (String src, long startPos) |
| Preloads a media resource. More... | |
| int | playPreloadedSrc (String src) |
| Plays preloaded media resources. More... | |
| int | unloadSrc (String src) |
| Unloads media resources that are preloaded. More... | |
| int | registerPlayerObserver (IMediaPlayerObserver playerObserver) |
| Registers a media player observer. More... | |
| int | unRegisterPlayerObserver (IMediaPlayerObserver playerObserver) |
| Releases a media player observer. More... | |
| int | registerAudioFrameObserver (IMediaPlayerAudioFrameObserver audioFrameObserver, int mode) |
| Registers an audio frame observer object. More... | |
| int | registerMediaPlayerAudioSpectrumObserver (IAudioSpectrumObserver observer, int intervalInMS) |
| int | unregisterMediaPlayerAudioSpectrumObserver (IAudioSpectrumObserver observer) |
| int | setAudioDualMonoMode (int mode) |
| Sets the channel mode of the current audio file. More... | |
| int | registerVideoFrameObserver (IMediaPlayerVideoFrameObserver videoFrameObserver) |
| Registers a video frame observer object. More... | |
| int | openWithAgoraCDNSrc (String src, long startPos) |
| int | getAgoraCDNLineCount () |
| int | switchAgoraCDNLineByIndex (int index) |
| int | getCurrentAgoraCDNIndex () |
| int | enableAutoSwitchAgoraCDN (boolean enable) |
| int | renewAgoraCDNSrcToken (String token, long ts) |
| int | switchAgoraCDNSrc (String src, boolean syncPts) |
| int | setSpatialAudioParams (SpatialAudioParams params) |
| Enables or disables the spatial audio effect for the media player. More... | |
| int io.agora.musiccontentcenter.IAgoraMusicPlayer.open | ( | long | songCode, |
| long | startPos | ||
| ) |
Opens a music resource by its resource ID.
Before calling this method, make sure the music resource you want to play has been fully loaded. You can call the isPreloaded method to check whether the music resource has been preloaded, or listen for the onPreLoadEvent callback. After calling this method, the onPlayerStateChanged callback will be triggered. Once you receive a playback state report of PLAYER_STATE_OPEN_COMPLETED, you can call the play method to play the media file.
open(String url, long startPos) method in the IMediaPlayer class.| songCode | The resource ID of the music resource, used to identify the music. |
| startPos | The starting playback position in milliseconds. The default value is 0. |
Error Codes for details and troubleshooting suggestions. | int io.agora.musiccontentcenter.IAgoraMusicPlayer.open | ( | String | url, |
| long | startPos | ||
| ) |
Opens a music resource via URL.
Calling this method triggers the onPlayerStateChanged callback. After receiving a report that the playback state is PLAYER_STATE_OPEN_COMPLETED, you can call the play method to play the media file.
open(String url, long startPos) method under the IMediaPlayer class.| url | The path to the music resource, supporting both local and online files. |
| startPos | The starting position for playback in milliseconds. Default is 0. |
Error Codes for details and troubleshooting suggestions. Implements io.agora.mediaplayer.IMediaPlayer.
| int io.agora.musiccontentcenter.IAgoraMusicPlayer.destroy | ( | ) |
Destroys the music player.
Error Codes for details and troubleshooting suggestions. Implements io.agora.mediaplayer.IMediaPlayer.
| String io.agora.musiccontentcenter.IAgoraMusicPlayer.getPlaySrc | ( | ) |
Gets the identifier or URL of the currently playing music resource.
You need to call this method after opening the music resource:
open(Uri uri, long startPos) method, this method returns the identifier of the music resource (songCode).open(String url, long startPos) method, this method returns the URL of the music resource.Implements io.agora.mediaplayer.IMediaPlayer.
| int io.agora.musiccontentcenter.IAgoraMusicPlayer.stop | ( | ) |
Stops playing the music resource.
Error Codes for details and troubleshooting tips. Implements io.agora.mediaplayer.IMediaPlayer.
| int io.agora.musiccontentcenter.IAgoraMusicPlayer.setPlayMode | ( | MusicPlayMode | mode | ) |
Sets the playback mode for a music track.
You can call this method to enable the original vocals, accompaniment, or vocal guide. If you do not call this method to set the mode, the accompaniment is played by default; if the music resource does not include accompaniment, the original vocals are played. Applicable scenarios: In entertainment scenarios such as online karaoke or talent shows, if you need to play licensed music provided by the Agora Content Center, you can call this method to set the playback mode. Call timing: You must call this method after createMusicPlayer.
onMusicCollectionResult callback, and use the list parameter in the callback to check which playback modes are supported for the licensed music.| mode | The playback mode. See MusicPlayMode for details. |
Error Codes for details and troubleshooting.
1.8.18