MediaLibrary Constructor (MediaSource)

Initializes a new instance of the MediaLibrary class, using a specific media source to create the new media library.

Namespace: Microsoft.Xna.Framework.Media
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public MediaLibrary (
         MediaSource mediaSource
)

Parameters

  • mediaSource
    A media source that will be the source for the media library.

Example

The following example demonstrates creating a new MediaLibrary class using a MediaSource.

GraphicsDevice.Clear(Color.CornflowerBlue);
Vector2 pos = Vector2.Zero;
SpriteFont font = Content.Load<SpriteFont>("Font");

spriteBatch.Begin();
spriteBatch.DrawString(font, "media library stats:", pos, Color.White);

ICollection<MediaSource> mediaSources = MediaSource.GetAvailableMediaSources();
foreach (MediaSource source in mediaSources)
{
    MediaLibrary ml = new MediaLibrary(source);
    
    // display some data about this media library
    pos.Y += font.LineSpacing;
    spriteBatch.DrawString(font, "Album count: " + ml.Albums.Count, pos, Color.White);
}

spriteBatch.End();

See Also

Reference

MediaLibrary Class
MediaSource Class
MediaLibrary Members
Microsoft.Xna.Framework.Media Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista, Zune