MediaSource.GetAvailableMediaSources Method

Gets the available media sources.

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

public static IList<MediaSource> GetAvailableMediaSources ()

Return Value

The available media sources.

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.

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

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

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

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


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

Community Additions