music controller now has constructor that creates music list for simplicity. Also now has listener for music list search event.

This commit is contained in:
Harrison Deng 2018-11-19 23:06:59 -06:00
parent 1bdda94905
commit 4da7243a60

View File

@ -11,7 +11,7 @@ namespace RhythmBullet.Zer01HD.Audio
{ {
internal class MusicController : IDisposable internal class MusicController : IDisposable
{ {
MusicList musicList; public readonly MusicList musicList;
WaveOutEvent outputDevice; WaveOutEvent outputDevice;
TransparentSampleProvider transparentSampleProvider; TransparentSampleProvider transparentSampleProvider;
AudioFileReader audioInput; AudioFileReader audioInput;
@ -49,11 +49,19 @@ namespace RhythmBullet.Zer01HD.Audio
LoadMusic(musicList.List[value]); LoadMusic(musicList.List[value]);
} }
} }
public MusicController()
{
musicList = new MusicList();
musicList.SearchCompleteEvent += MusicListRefreshListener;
random = new Random();
}
public MusicController(MusicList musicList) public MusicController(MusicList musicList)
{ {
this.musicList = musicList;
random = new Random(); random = new Random();
this.musicList = musicList;
this.musicList.SearchCompleteEvent += MusicListRefreshListener;
} }
private void LoadMusic(string path) private void LoadMusic(string path)
@ -109,6 +117,11 @@ namespace RhythmBullet.Zer01HD.Audio
{ {
audioInput?.Dispose(); audioInput?.Dispose();
outputDevice?.Dispose(); outputDevice?.Dispose();
musicList.SearchCompleteEvent -= MusicListRefreshListener;
}
public void MusicListRefreshListener(MusicList musicList)
{
} }
} }
} }