Music Player
FreakLib.Music.MusicPlayer Class Reference

This class implements a MusicPlayer for Unity. More...

Inheritance diagram for FreakLib.Music.MusicPlayer:

Classes

class  MusicPlayerEvent
 A custom UnityEvent, which allows passing a MusicPlayer as an argument. More...
 

Public Member Functions

void Play ()
 Starts playing the current Playlist, or the first defined Playlist if the current Playlist is not set. More...
 
void Play (string name)
 Starts playing the specified Playlist. More...
 
void Play (Playlist playlist)
 Starts playing the specified Playlist. More...
 
void PauseOrResume ()
 Calling this will Pause the MusicPlayer if it is playing, or resume from pause if it is currently paused. More...
 
void Pause ()
 Pause the MusicPlayer. More...
 
void UnPause ()
 UnPause the MusicPlayer (resume from pause). More...
 
void Stop ()
 Stops the MusicPlayer. More...
 
void Next ()
 Skip to the next Track. More...
 
void Previous ()
 Skip to the previous Track. More...
 
Playlist GetPlaylist (string name)
 Get the Playlist with the given name. More...
 

Public Attributes

MusicPlayerEvent OnPlay
 A UnityEvent that will fire when we start playing. More...
 
MusicPlayerEvent OnStop
 A UnityEvent that will fire when we stop playing. More...
 
MusicPlayerEvent OnPause
 A UnityEvent that will fire when we pause. More...
 
MusicPlayerEvent OnUnpause
 A UnityEvent that will fire when we un-pause. More...
 
MusicPlayerEvent OnTrackChange
 A UnityEvent that will fire when we change track. More...
 
MusicPlayerEvent OnPlaylistChange
 A UnityEvent that will fire when we change Playlist. More...
 

Properties

bool PlayOnAwake [get, set]
 Gets or sets a value indicating whether this MusicPlayer should play on awake. More...
 
float Volume [get, set]
 Gets or sets the volume. More...
 
int HistoryLength [get, set]
 Gets or sets the length of the history. More...
 
List< PlaylistPlaylists [get, set]
 Gets the playlists. More...
 
List< string > PlaylistNames [get]
 Gets the playlist names. More...
 
Playlist CurrentPlaylist [get]
 Gets the current playlist. More...
 
string CurrentPlaylistName [get]
 Gets the name of the current playlist. More...
 
Track CurrentTrack [get]
 Gets the current track. More...
 
string CurrentTrackName [get]
 Gets the name of the current track. More...
 
bool IsPlaying [get]
 Gets a value indicating if we are currently playing. More...
 
float Playtime [get, set]
 Gets the current playtime, in seconds. Will be a value between 0 and the track length. More...
 
float PlaytimeNormalized [get, set]
 Gets the current playtime normalized. Will be a value between 0 and 1. More...
 

Detailed Description

This class implements a MusicPlayer for Unity.

The MusicPlayer will play a Playlist, either in order or shuffled, and allows pausing, skipping tracks forward and back, as well as seeking.

It will also send various UnityEvents when changing tracks, playlists and so on.

Member Function Documentation

Playlist FreakLib.Music.MusicPlayer.GetPlaylist ( string  name)

Get the Playlist with the given name.

Returns null if a playlist is not found.

Returns
The playlist.
Parameters
nameThe name of the Playlist.
void FreakLib.Music.MusicPlayer.Next ( )

Skip to the next Track.

void FreakLib.Music.MusicPlayer.Pause ( )

Pause the MusicPlayer.

void FreakLib.Music.MusicPlayer.PauseOrResume ( )

Calling this will Pause the MusicPlayer if it is playing, or resume from pause if it is currently paused.

void FreakLib.Music.MusicPlayer.Play ( )

Starts playing the current Playlist, or the first defined Playlist if the current Playlist is not set.

Calling Play will always start playing, regardless of the current state of the MusicPlayer. It will also reset the Playlist.

void FreakLib.Music.MusicPlayer.Play ( string  name)

Starts playing the specified Playlist.

The name should match a Playlist defined in this instance of the MusicPlayer. If the specified playlist is not found, a UnityException is thrown.

Parameters
nameThe name of the Playlist to play.
void FreakLib.Music.MusicPlayer.Play ( Playlist  playlist)

Starts playing the specified Playlist.

The specified Playlist does not necessarily need to be defined in this instance of the MusicPlayer, but can be generated and passed in as a separate instance.

Parameters
playlistPlaylist.
void FreakLib.Music.MusicPlayer.Previous ( )

Skip to the previous Track.

void FreakLib.Music.MusicPlayer.Stop ( )

Stops the MusicPlayer.

void FreakLib.Music.MusicPlayer.UnPause ( )

UnPause the MusicPlayer (resume from pause).

Member Data Documentation

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnPause

A UnityEvent that will fire when we pause.

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnPlay

A UnityEvent that will fire when we start playing.

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnPlaylistChange

A UnityEvent that will fire when we change Playlist.

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnStop

A UnityEvent that will fire when we stop playing.

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnTrackChange

A UnityEvent that will fire when we change track.

MusicPlayerEvent FreakLib.Music.MusicPlayer.OnUnpause

A UnityEvent that will fire when we un-pause.

Property Documentation

Playlist FreakLib.Music.MusicPlayer.CurrentPlaylist
get

Gets the current playlist.

The current playlist.

string FreakLib.Music.MusicPlayer.CurrentPlaylistName
get

Gets the name of the current playlist.

The name of the current playlist.

Track FreakLib.Music.MusicPlayer.CurrentTrack
get

Gets the current track.

The current track.

string FreakLib.Music.MusicPlayer.CurrentTrackName
get

Gets the name of the current track.

The name of the current track.

int FreakLib.Music.MusicPlayer.HistoryLength
getset

Gets or sets the length of the history.

The length of the history.

bool FreakLib.Music.MusicPlayer.IsPlaying
get

Gets a value indicating if we are currently playing.

true if playing; otherwise, false.

List<string> FreakLib.Music.MusicPlayer.PlaylistNames
get

Gets the playlist names.

The playlist names.

List<Playlist> FreakLib.Music.MusicPlayer.Playlists
getset

Gets the playlists.

The playlists.

bool FreakLib.Music.MusicPlayer.PlayOnAwake
getset

Gets or sets a value indicating whether this MusicPlayer should play on awake.

true if play on awake; otherwise, false.

float FreakLib.Music.MusicPlayer.Playtime
getset

Gets the current playtime, in seconds. Will be a value between 0 and the track length.

The playtime.

float FreakLib.Music.MusicPlayer.PlaytimeNormalized
getset

Gets the current playtime normalized. Will be a value between 0 and 1.

The playtime normalized.

float FreakLib.Music.MusicPlayer.Volume
getset

Gets or sets the volume.

The volume.


The documentation for this class was generated from the following file: