2 using Microsoft.Xna.Framework.Content;
4 using XnaSong = Microsoft.Xna.Framework.Media.Song;
6 using Microsoft.Xna.Framework.Media;
15 private ContentManager content;
22 get {
return Microsoft.Xna.Framework.Media.MediaPlayer.Volume; }
23 set { Microsoft.Xna.Framework.Media.MediaPlayer.Volume = (float)value; }
36 Microsoft.Xna.Framework.FrameworkDispatcher.Update();
37 return Microsoft.Xna.Framework.Media.MediaPlayer.GameHasControl;
49 get {
return Microsoft.Xna.Framework.Media.MediaPlayer.IsMuted; }
50 set { Microsoft.Xna.Framework.Media.MediaPlayer.IsMuted = value; }
58 get {
return Microsoft.Xna.Framework.Media.MediaPlayer.IsRepeating; }
59 set { Microsoft.Xna.Framework.Media.MediaPlayer.IsRepeating = value; }
67 get {
return Microsoft.Xna.Framework.Media.MediaPlayer.State == MediaState.Playing; }
72 this.content = content;
79 public void Play(
string songName )
86 song = content.Load<
XnaSong>( songName );
88 catch ( ContentLoadException e )
91 "Could not play the song \"" + songName +
"\".\n" +
92 "Please check that you added the song to the Content project and typed the name correctly.", e );
94 Microsoft.Xna.Framework.Media.MediaPlayer.Play( song );
98 public void PlayFromFile(
string fileName )
108 var ctor = typeof( Song ).GetConstructor(
109 BindingFlags.NonPublic | BindingFlags.Instance, null,
110 new[] { typeof( string ), typeof( string ), typeof( int ) }, null );
112 Song song = (Song)ctor.Invoke(
new object[] {
"name", fileName, 0 } );
113 Microsoft.Xna.Framework.Media.MediaPlayer.Play( song );
125 Song song = Song.FromUri(
"song",
new Uri( url ) );
126 Microsoft.Xna.Framework.Media.MediaPlayer.Play( song );
135 Microsoft.Xna.Framework.Media.MediaPlayer.Pause();
144 Microsoft.Xna.Framework.Media.MediaPlayer.Resume();
153 Microsoft.Xna.Framework.Media.MediaPlayer.Stop();