Class MusicPlaylist
Playlist of Music Ids (library name + music name) that can be played by a MusicPlayer
Inherited Members
Namespace: Doozy.Runtime.Soundy
Assembly: cs.temp.dll.dll
Syntax
public class MusicPlaylist
Properties
canPlay
Check if the playlist can play (if it has at least one valid music id)
Declaration
public bool canPlay { get; }
Property Value
Type | Description |
---|---|
Boolean |
count
Number of music ids in the playlist
Declaration
public int count { get; }
Property Value
Type | Description |
---|---|
Int32 |
currentMusicId
Current music id that is playing
Declaration
public MusicId currentMusicId { get; }
Property Value
Type | Description |
---|---|
MusicId |
currentMusicIdIndex
Index of the current music id that is playing
Declaration
public int currentMusicIdIndex { get; }
Property Value
Type | Description |
---|---|
Int32 |
ids
List of Music Ids (library name + music name) that this playlist is referencing
Declaration
public List<MusicId> ids { get; }
Property Value
Type | Description |
---|---|
List<MusicId> |
isEmpty
Check if the playlist is empty (if it has no valid music ids)
Declaration
public bool isEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
loopPlaylist
Loop the playlist (works only if Play Mode is Sequential)
Declaration
public bool loopPlaylist { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
loopSong
Loop the current song over and over (if enabled) If enabled, LoadNext will start playing the current song again, instead of loading the next one
Declaration
public bool loopSong { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
playedIds
List of Music Ids (library name + music name) that have been played. This is use to keep track of the played songs and be used like a history.
Declaration
public List<MusicId> playedIds { get; }
Property Value
Type | Description |
---|---|
List<MusicId> |
playMode
Play mode for this MusicPlayer
Declaration
public PlayMode playMode { get; set; }
Property Value
Type | Description |
---|---|
PlayMode |
previousMusicId
Previous music id that was played
Declaration
public MusicId previousMusicId { get; }
Property Value
Type | Description |
---|---|
MusicId |
previousMusicIdIndex
Index of the previous music id that was played
Declaration
public int previousMusicIdIndex { get; }
Property Value
Type | Description |
---|---|
Int32 |
validIdsCount
Number of valid music ids in the playlist (not null and valid)
Declaration
public int validIdsCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Add(MusicId)
Add a music id to the playlist. If a music id already exists in the playlist, it will not be added again.
Declaration
public MusicPlaylist Add(MusicId musicId)
Parameters
Type | Name | Description |
---|---|---|
MusicId | musicId | Music id to add |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Add(String, String)
Add a music id to the playlist. If a music id with the same library name and music name already exists in the playlist, a new music id with the same library name and music name will be added.
Declaration
public MusicId Add(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Name of the library where the music is located |
String | musicName | Name of the music |
Returns
Type | Description |
---|---|
MusicId | The music id that was added, or if the music id already exists, the existing music id with the same library name and music name |
AddNew()
Add a music id to the playlist with the default library name and default audio name.
Declaration
public MusicId AddNew()
Returns
Type | Description |
---|---|
MusicId | The music id that was added, or if the music id already exists, the existing music id with the default library name and default audio name |
Clear()
Clear the playlist and reset the current music id and index
Declaration
public MusicPlaylist Clear()
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Contains(String, String)
Check if the playlist contains a music id with the given library name and music name.
Declaration
public bool Contains(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Library name |
String | musicName | Music name |
Returns
Type | Description |
---|---|
Boolean | TRUE if the playlist contains a music id with the given library name and music name |
GetMusicId(Int32)
Get the music id at the given index. If the index is invalid, null is returned.
Declaration
public MusicId GetMusicId(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the music id in the playlist |
Returns
Type | Description |
---|---|
MusicId | Music id (it can be null if it was not found) |
GetMusicId(String, String)
Get the music id at the given library name and music name. If a music id with the given library name and music name is not found, null is returned.
Declaration
public MusicId GetMusicId(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Library name |
String | musicName | Music name |
Returns
Type | Description |
---|---|
MusicId | Music id (it can be null if it was not found) |
IndexOf(MusicId)
Get the index of the given music id. If the music id does not exist in the playlist, -1 will be returned.
Declaration
public int IndexOf(MusicId musicId)
Parameters
Type | Name | Description |
---|---|---|
MusicId | musicId | Music id to get the index of |
Returns
Type | Description |
---|---|
Int32 | The index of the given music id, or -1 if the music id does not exist in the playlist |
IndexOf(String, String)
Get the index of the first music id with the given library name and music name. If a music id with the given library name and music name does not exist in the playlist, -1 will be returned.
Declaration
public int IndexOf(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Name of the library where the music is located |
String | musicName | Name of the music |
Returns
Type | Description |
---|---|
Int32 | The index of the first music id with the given library name and music name, or -1 if a music id with the given library name and music name does not exist in the playlist |
Insert(Int32, MusicId)
Insert a music id to the playlist at the specified index. If the index is out of range, the music id will be added to the beginning or the end of the playlist (depending on the provided index).
Declaration
public MusicPlaylist Insert(int index, MusicId musicId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index to insert the music id at |
MusicId | musicId | Music id to insert |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Insert(Int32, String, String)
Insert a music id with the specified library name and music name to the playlist at the specified index. If the index is out of range, the music id will be added to the beginning or the end of the playlist (depending on the provided index).
Declaration
public MusicId Insert(int index, string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index to insert the music id at |
String | libraryName | Name of the library where the music is located |
String | musicName | Name of the music |
Returns
Type | Description |
---|---|
MusicId | The music id that was inserted, or if the music id already exists, the existing music id with the same library name and music name |
LoadNext()
Loads the next music id in the playlist, based on the current play mode. After the next music id is loaded, it is set as the current music id.
Declaration
public MusicId LoadNext()
Returns
Type | Description |
---|---|
MusicId | Next music id in the playlist (based on the current play mode) |
LoadPrevious()
Loads the previous music id in the playlist, if there is one. After the previous music id is loaded, it is set as the current music id.
Declaration
public MusicId LoadPrevious()
Returns
Type | Description |
---|---|
MusicId | Previous music id in the playlist (if there is one) |
Remove(MusicId)
Removes the given music id from the playlist. If the music id does not exist in the playlist, nothing will happen.
Declaration
public MusicPlaylist Remove(MusicId musicId)
Parameters
Type | Name | Description |
---|---|---|
MusicId | musicId | Music id to remove |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Remove(String, String)
Removes the first music id with the given library name and music name from the playlist. If a music id with the given library name and music name does not exist in the playlist, nothing will happen.
Declaration
public MusicPlaylist Remove(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Name of the library where the music is located |
String | musicName | Name of the music |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
RemoveAt(Int32)
Removes the music id at the given index from the playlist. If the index is out of range, nothing will happen.
Declaration
public MusicPlaylist RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the music id to remove |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
RemoveInvalids()
Remove all invalid music ids from the playlist. A music id is considered invalid if it is null, empty or has the 'None' library name or music name.
Declaration
public MusicPlaylist RemoveInvalids()
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
RemoveNulls()
Remove all null music ids from the playlist. Note that this keeps any ids that have the 'None' library name and/or 'None' music name (these do not work, but are not null).
Declaration
public MusicPlaylist RemoveNulls()
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Reset()
Reset the playlist to its default values. This will reset the previous and current music ids and their indexes.
Declaration
public void Reset()
SetLoop(Boolean)
Set the playlist to loop or not
Declaration
public MusicPlaylist SetLoop(bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value | If TRUE, the playlist will loop when it reaches the end |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
SetLoopCurrentSong(Boolean)
Set the playlist to loop the current song or not
Declaration
public MusicPlaylist SetLoopCurrentSong(bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value | If TRUE, the playlist will loop the current song |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
SetNext(Int32)
Set the current music id to the music id at the given index. If the index is invalid, the current music id is returned (it can be null).
Declaration
public MusicId SetNext(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the music id in the playlist |
Returns
Type | Description |
---|---|
MusicId | Current music id (it can be null if it was not set or is invalid) |
SetNext(String, String)
Set the current music id to the music id at the given library name and music name. If a music id with the given library name and music name is not found, the current music id is returned (it can be null).
Declaration
public MusicId SetNext(string libraryName, string musicName)
Parameters
Type | Name | Description |
---|---|---|
String | libraryName | Library name |
String | musicName | Music name |
Returns
Type | Description |
---|---|
MusicId | Current music id (it can be null if it was not set or is invalid) |
SetPlayMode(PlayMode)
Set the playlist play mode
Declaration
public MusicPlaylist SetPlayMode(PlayMode value)
Parameters
Type | Name | Description |
---|---|---|
PlayMode | value | Play mode |
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |
Validate()
Validate the playlist by removing all null music ids and all invalid music ids. A music id is considered invalid if it is null, empty or has the 'None' library name or music name.
Declaration
public MusicPlaylist Validate()
Returns
Type | Description |
---|---|
MusicPlaylist | This playlist (for method chaining) |