41 lines
677 B
C#
41 lines
677 B
C#
using Microsoft.Xna.Framework.Audio;
|
|
using System;
|
|
|
|
namespace SemiColinGames {
|
|
public class MusicPlayer : IDisposable {
|
|
|
|
private SoundEffectInstance music;
|
|
|
|
~MusicPlayer() {
|
|
Dispose();
|
|
}
|
|
|
|
public void Dispose() {
|
|
Stop();
|
|
music?.Dispose();
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
public void Load(SoundEffect sound) {
|
|
if (sound == null) {
|
|
return;
|
|
}
|
|
music = sound.CreateInstance();
|
|
music.IsLooped = true;
|
|
music.Volume = 0.1f;
|
|
}
|
|
|
|
public void Stop() {
|
|
music?.Stop();
|
|
}
|
|
|
|
public void Pause() {
|
|
music?.Pause();
|
|
}
|
|
|
|
public void Play() {
|
|
music?.Play();
|
|
}
|
|
}
|
|
}
|