Table of Contents

Class SongCollection

Namespace
Microsoft.Xna.Framework.Media
Assembly
MonoGame.Framework.dll

A collection of songs in the song library.

public class SongCollection : ICollection<Song>, IEnumerable<Song>, IEnumerable, IDisposable
Inheritance
SongCollection
Implements
Inherited Members

Remarks

The SongCollection class provides access to songs in the device's song library.

Use the Songs property to obtain the following collections: All songs in the media library; Songs on a particular album; Songs associated with a particular artist; Songs associated with a particular genre;

Fields

Empty

Returns a SongCollection with no contents.

public static readonly SongCollection Empty

Field Value

SongCollection

Properties

Count

Gets the number of Song objects in the SongCollection.

public int Count { get; }

Property Value

int

IsReadOnly

Gets whether this collection is read-only,

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets the Song at the specified index in the SongCollection.

public Song this[int index] { get; }

Parameters

index int

Property Value

Song

Methods

Add(Song)

Adds a Song to this SongCollection.

public void Add(Song item)

Parameters

item Song

Clear()

Removes all items from this SongCollection.

public void Clear()

Clone()

Creates a new object that is a copy of the current instance.

public SongCollection Clone()

Returns

SongCollection

A new object that is a copy of this instance.

Contains(Song)

Determines whether a Song is in the SongCollection

public bool Contains(Song item)

Parameters

item Song

Returns

bool

true if item is found in the SongCollection; otherwise, false.

CopyTo(Song[], int)

Copies the elements of the collection to an Array, starting at a particular Array index.

public void CopyTo(Song[] array, int arrayIndex)

Parameters

array Song[]

The one-dimensional Array that is the destination of the elements copied from collection. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<Song> GetEnumerator()

Returns

IEnumerator<Song>

An enumerator that can be used to iterate through the collection.

IndexOf(Song)

Searches for the specified Song and returns the zero-based index of the first occurence within the entire SongCollection.

public int IndexOf(Song item)

Parameters

item Song

The Song to locate

Returns

int

The zero-based index of the first occurence of item within the entire SongCollection, if found. otherwise, -1.

Remove(Song)

Removes the first occurrence of a Song from the SongCollection.

public bool Remove(Song item)

Parameters

item Song

The object to remove from the SongCollection.

Returns

bool

true if item was successfully removed from the SongCollection; otherwise, false. This method also returns false if item is not found in the original SongCollection.