Methods

Some of these can be outdated.

Initialize

  • Description: Initializes the media player with a single media item.

  • Usage:

    MediaItem mediaItem = new MediaItem(/* parameters */);
    MediaPlayer.Initialize(mediaItem, true);

Initialize (Playlist)

  • Description: Initializes the media player with a playlist.

  • Usage:

    Playlist playlist = new Playlist(/* parameters */);
    MediaPlayer.Initialize(playlist, true, 0);

Initialize (Multiple Playlists)

  • Description: Initializes the media player with multiple playlists.

  • Usage:

    IEnumerable<Playlist> playlists = new List<Playlist> { /* parameters */ };
    MediaPlayer.Initialize(playlists, true, 0, 0);

SetPlaylist

  • Description: Sets the current playlist by index.

  • Usage:

    MediaPlayer.SetPlaylist(0, true, 0, () => Debug.Log("Playlist loaded"));

Play

  • Description: Starts media playback.

  • Usage:

    MediaPlayer.Play();

Play (With Media Item Index)

  • Description: Starts playback of a specific media item by index.

  • Usage:

    MediaPlayer.Play(1); // Example index

Stop

  • Description: Stops media playback.

  • Usage:

    MediaPlayer.Stop();

FadeIn

  • Description: Gradually increases the volume over the specified duration.

  • Usage:

    MediaPlayer.FadeIn(2.0f); // 2 seconds

FadeOut

  • Description: Gradually decreases the volume over the specified duration.

  • Usage:

    MediaPlayer.FadeOut(2.0f); // 2 seconds

SetBackgroundControls

  • Description: Enables or disables background controls.

  • Usage:

    MediaPlayer.SetBackgroundControls(true);

SetBackgroundMode

  • Description: Enables or disables background mode.

  • Usage:

    MediaPlayer.SetBackgroundMode(true);

Release

  • Description: Releases the media player resources.

  • Usage:

    MediaPlayer.Release();

Pause

  • Description: Pauses media playback.

  • Usage:

    MediaPlayer.Pause();

Previous

  • Description: Plays the previous media item.

  • Usage:

    MediaPlayer.Previous();

Next

  • Description: Plays the next media item.

  • Usage:

    MediaPlayer.Next();

FastForward

  • Description: Fast forwards the current media item.

  • Usage:

    MediaPlayer.FastForward();

Rewind

  • Description: Rewinds the current media item.

  • Usage:

    MediaPlayer.Rewind();

SeekTo

  • Description: Seeks to a specific time in the current media item.

  • Usage:

    MediaPlayer.SeekTo(60.0f); // 60 seconds

GetDuration

  • Description: Gets the duration of the current media item.

  • Usage:

    float duration = MediaPlayer.GetDuration();

GetCurrentPosition

  • Description: Gets the current playback position.

  • Usage:

    float position = MediaPlayer.GetCurrentPosition();

GetShuffleOrder

  • Description: Gets the shuffle order of the current playlist.

  • Usage:

    int[] shuffleOrder = MediaPlayer.GetShuffleOrder();

AddMediaItem

  • Description: Adds a media item to the current playlist.

  • Usage:

    MediaItem newItem = new MediaItem(/* parameters */);
    MediaPlayer.AddMediaItem(newItem);

RemoveMediaItem

  • Description: Removes a media item from the current playlist.

  • Usage:

    MediaPlayer.RemoveMediaItem(1); // Example index

Play (Media Item)

  • Description: Plays a specified media item.

  • Usage:

    MediaItem mediaItem = new MediaItem(/* parameters */);
    MediaPlayer.Play(mediaItem);

PlayRemoteUrl

  • Description: Plays a media item from a remote URL.

  • Usage:

    MediaPlayer.PlayRemoteUrl("http://example.com/media.mp3");

PlayStreamingAsset

  • Description: Plays a media item from the StreamingAssets folder.

  • Usage:

    MediaPlayer.PlayStreamingAsset("path/to/asset.mp3");

SetPlaybackSpeed

  • Description: Sets the playback speed of the media player.

  • Usage:

    MediaPlayer.SetPlaybackSpeed(1.5f); // 1.5x speed

AddPlaylist

  • Description: Adds a playlist to the collection.

  • Returns: int (Index of the added playlist)

  • Usage:

    Playlist playlist = new Playlist(/* parameters */);
    int index = MediaPlayer.AddPlaylist(playlist);

SetPlaylists

  • Description: Sets the collection of playlists.

  • Usage:

    IEnumerable<Playlist> playlists = new List<Playlist> { /* parameters */ };
    MediaPlayer.SetPlaylists(playlists);

GetPlaylist

  • Description: Gets a playlist by its index.

  • Returns: Playlist

  • Usage:

    Playlist playlist = MediaPlayer.GetPlaylist(0);

GetMediaItem

  • Description: Gets a media item by its index and optionally by playlist index.

  • Returns: MediaItem

  • Usage:

    MediaItem item = MediaPlayer.GetMediaItem(0, 1);

SetPlaylistUpdated

  • Description: Sets the current playlist index and indicates that the playlist is no longer loading.

  • Usage:

    MediaPlayer.SetPlaylistUpdated();

Play

  • Description: Starts media playback.

  • Usage:

    MediaPlayer.Play();

Play (With Media Item Index)

  • Description: Starts playback of a specific media item by index.

  • Usage:

    MediaPlayer.Play(1); // Example index

Stop

  • Description: Stops media playback.

  • Usage:

    MediaPlayer.Stop();

FadeIn

  • Description: Gradually increases the volume over the specified duration.

  • Usage:

    MediaPlayer.FadeIn(2.0f); // 2 seconds

FadeOut

  • Description: Gradually decreases the volume over the specified duration.

  • Usage:

    MediaPlayer.FadeOut(2.0f); // 2 seconds

SetBackgroundControls

  • Description: Enables or disables background controls.

  • Usage:

    MediaPlayer.SetBackgroundControls(true);

SetBackgroundMode

  • Description: Enables or disables background mode.

  • Usage:

    MediaPlayer.SetBackgroundMode(true);

Release

  • Description: Releases the media player resources.

  • Usage:

    MediaPlayer.Release();

Pause

  • Description: Pauses media playback.

  • Usage:

    MediaPlayer.Pause();

Previous

  • Description: Plays the previous media item.

  • Usage:

    MediaPlayer.Previous();

Next

  • Description: Plays the next media item.

  • Usage:

    MediaPlayer.Next();

HasPreviousMediaItem

  • Description: Checks if there is a previous media item.

  • Usage:

    bool hasPrevious = MediaPlayer.HasPreviousMediaItem();

HasNextMediaItem

  • Description: Checks if there is a next media item.

  • Usage:

    bool hasNext = MediaPlayer.HasNextMediaItem();

FastForward

  • Description: Fast forwards the current media item.

  • Usage:

    MediaPlayer.FastForward();

Rewind

  • Description: Rewinds the current media item.

  • Usage:

    MediaPlayer.Rewind();

SeekTo

  • Description: Seeks to a specific time in the current media item.

  • Usage:

    MediaPlayer.SeekTo(60.0f); // 60 seconds

GetDuration

  • Description: Gets the duration of the current media item.

  • Usage:

    float duration = MediaPlayer.GetDuration();

GetCurrentPosition

  • Description: Gets the current playback position.

  • Usage:

    float position = MediaPlayer.GetCurrentPosition();

GetShuffleOrder

  • Description: Gets the shuffle order of the current playlist.

  • Usage:

    int[] shuffleOrder = MediaPlayer.GetShuffleOrder();

AddMediaItem

  • Description: Adds a media item to the current playlist.

  • Usage:

    MediaItem newItem = new MediaItem(/* parameters */);
    MediaPlayer.AddMediaItem(newItem);

RemoveMediaItem

  • Description: Removes a media item from the current playlist.

  • Usage:

    MediaPlayer.RemoveMediaItem(1); // Example index

Play (Media Item)

  • Description: Plays a specified media item.

  • Usage:

    MediaItem mediaItem = new MediaItem(/* parameters */);
    MediaPlayer.Play(mediaItem);

PlayRemoteUrl

  • Description: Plays a media item from a remote URL.

  • Usage:

    MediaPlayer.PlayRemoteUrl("http://example.com/media.mp3");

PlayStreamingAsset

  • Description: Plays a media item from the StreamingAssets folder.

  • Usage:

    MediaPlayer.PlayStreamingAsset("path/to/asset.mp3");

SetPlaybackSpeed

  • Description: Sets the playback speed of the media player.

  • Usage:

    MediaPlayer.SetPlaybackSpeed(1.5f); // 1.5x speed

Last updated