La sonorisation
CHAPITRE 7
143
SpriteBatch spriteBatch;
MediaLibrary sampleMediaLibrary;
Random rand;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
sampleMediaLibrary = new MediaLibrary();
rand = new Random();
}
protected override void Initialize()
{
ServiceHelper.Game = this;
Components.Add(new KeyboardService(this));
int i = rand.Next(0, sampleMediaLibrary.Albums.Count - 1);
MediaPlayer.Play(sampleMediaLibrary.Albums[i].Songs[0]);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (ServiceHelper.Get().IsKeyDown(Keys.Space))
{
if (MediaPlayer.State == MediaState.Playing)
MediaPlayer.Pause();
else
MediaPlayer.Resume();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
=Labat FM.book Page 143 Vendredi, 19. juin 2009 4:01 16
CHAPITRE 7
143
SpriteBatch spriteBatch;
MediaLibrary sampleMediaLibrary;
Random rand;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
sampleMediaLibrary = new MediaLibrary();
rand = new Random();
}
protected override void Initialize()
{
ServiceHelper.Game = this;
Components.Add(new KeyboardService(this));
int i = rand.Next(0, sampleMediaLibrary.Albums.Count - 1);
MediaPlayer.Play(sampleMediaLibrary.Albums[i].Songs[0]);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (ServiceHelper.Get
{
if (MediaPlayer.State == MediaState.Playing)
MediaPlayer.Pause();
else
MediaPlayer.Resume();
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}
=Labat FM.book Page 143 Vendredi, 19. juin 2009 4:01 16
