Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 16th, 2013  |  syntax: None  |  size: 2.16 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.Xna.Framework;
  5. using Microsoft.Xna.Framework.Audio;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework.GamerServices;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10. using Microsoft.Xna.Framework.Media;
  11. using System.IO;
  12.  
  13. namespace Test
  14. {
  15.     /// <summary>
  16.     /// This is the main type for your game
  17.     /// </summary>
  18.     public class Game1 : Microsoft.Xna.Framework.Game
  19.     {
  20.         GraphicsDeviceManager graphics;
  21.         SpriteBatch spriteBatch;
  22.         string[] SongsToRead = Directory.GetFiles(Environment.CurrentDirectory, "*.mp3");
  23.         Song Song;
  24.  
  25.         public Game1()
  26.         {
  27.             graphics = new GraphicsDeviceManager(this);
  28.             Content.RootDirectory = "Content";
  29.            
  30.         }
  31.  
  32.         protected override void Initialize()
  33.         {
  34.             var var1 = Uri.EscapeUriString(SongsToRead[0]);
  35.             Song = Song.FromUri("Test", new Uri(var1));
  36.             base.Initialize();
  37.         }
  38.  
  39.         protected override void LoadContent()
  40.         {
  41.             spriteBatch = new SpriteBatch(GraphicsDevice);
  42.         }
  43.        
  44.         protected override void UnloadContent()
  45.         {
  46.            
  47.         }
  48.  
  49.         protected override void Update(GameTime gameTime)
  50.         {
  51.             // Allows the game to exit
  52.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  53.                 this.Exit();
  54.             if (Keyboard.GetState().IsKeyDown(Keys.A))
  55.             {
  56.                 MediaPlayer.Play(Song);  
  57.             }
  58.  
  59.             // TODO: Add your update logic here
  60.  
  61.             base.Update(gameTime);
  62.         }
  63.  
  64.         /// <summary>
  65.         /// This is called when the game should draw itself.
  66.         /// </summary>
  67.         /// <param name="gameTime">Provides a snapshot of timing values.</param>
  68.         protected override void Draw(GameTime gameTime)
  69.         {
  70.             GraphicsDevice.Clear(Color.CornflowerBlue);
  71.  
  72.             // TODO: Add your drawing code here
  73.  
  74.             base.Draw(gameTime);
  75.         }
  76.     }
  77. }