private void Play(string filePath) { // return if play is auto play is disabled if (!autoPlayCheckBox.Checked) { return; } player = BassProxy.Instance; if (player != null) { player.Stop(); player.OpenFile(filePath); if (player.CanPlay) { player.Play(); } else { Debug.WriteLine("Failed playing using Un4Seen Bass, trying to use mplayer ..."); float[] audioData = Mirage.AudioFileReader.Decode(filePath, Analyzer.SAMPLING_RATE, Analyzer.SECONDS_TO_ANALYZE); if (audioData != null && audioData.Length > 0) { player = NAudioProxy.GetWaveOutInstance(); if (player != null) { NAudioFloatArrayProvider provicer = new NAudioFloatArrayProvider(Analyzer.SAMPLING_RATE, audioData, 2); ((NAudioProxy)player).OpenSampleProvider(provicer); if (player.CanPlay) { player.Play(); } else { MessageBox.Show("Could not play file!", "Error playing file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } }
private void Play(string filePath) { // return if play is auto play is disabled if (!autoPlayCheckBox.Checked) return; player = BassProxy.Instance; if (player != null) { player.Stop(); player.OpenFile(filePath); if (player.CanPlay) { player.Play(); } else { Debug.WriteLine("Failed playing using Un4Seen Bass, trying to use mplayer ..."); float[] audioData = Mirage.AudioFileReader.Decode(filePath, Analyzer.SAMPLING_RATE, Analyzer.SECONDS_TO_ANALYZE); if (audioData != null && audioData.Length > 0) { player = NAudioProxy.GetWaveOutInstance(); if (player != null) { NAudioFloatArrayProvider provicer = new NAudioFloatArrayProvider(Analyzer.SAMPLING_RATE, audioData, 2); ((NAudioProxy) player).OpenSampleProvider(provicer); if (player.CanPlay) { player.Play(); } else { MessageBox.Show("Could not play file!", "Error playing file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } }