Share via


MediaSource.GetAvailableMediaSources Method

Gets the available media sources.

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

Syntax

public static IList<MediaSource> GetAvailableMediaSources ()

Return Value

The available media sources.

Remarks

Gets the available media sources with which a media library can be constructed. On Windows Phone and Windows, this method will always return a single media source: the local device. On Xbox 360, this method can return multiple sources, depending on how many computers are connected to the Xbox 360 through Windows Media Connect.

Example

The following example demonstrates how the GetAvailableMediaSources method gets and displays the current media sources.

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

spriteBatch.Begin();
spriteBatch.DrawString(font, "media source(s):", pos, Color.White);

ICollection<MediaSource> mediaSources = 
    MediaSource.GetAvailableMediaSources();
foreach (MediaSource source in mediaSources)
{
    pos.Y += font.LineSpacing;
    spriteBatch.DrawString(font, source.Name, pos, Color.White);
}

spriteBatch.End();

See Also

Reference

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

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone