Playing a Song from a URI
Demonstrates how to use the MediaPlayer to play a song from a Uniform Resource Identifier (URI).
Playing a Song from a URI
To play a song from a URI
The following steps show you how to play an .mp3 song located on the Internet.
-
Set MediaPlayer play state to stopped.
-
Declare a new instance of Uri using the full URI path to the song.
-
Use the FromUri method to supply an arbitrary string name for the URI, and then pass the Uri object you created in the previous step.
-
Play the song.
Concepts
- Playing a Song
- Demonstrates how to play a song from a user's media library.
- Media Overview
- Provides a high-level overview about the capabilities—such as playing music and video and accessing pictures—of the Media API in XNA Game Studio.
Reference
- MediaPlayer Class
- Provides methods and properties to play, pause, resume, and stop songs. MediaPlayer also exposes shuffle, repeat, volume, play position, and visualization capabilities.
- Song Class
- Provides access to a song in the song library.