//Stop without next song public bool stopSound() { PlaybackStopType = PlaybackStopTypes.PlaybackStoppedByUser; if (playing) { outputDevice?.Dispose(); outputDevice = null; try { audioFile?.Dispose(); } catch (Exception ex) { Debug.Print("exception: " + ex.ToString()); } audioFile = null; playing = false; return(true); } else { outputDevice?.Stop(); audioFile?.Dispose(); audioFile = null; return(false); } }
private void nextButton_Click(object sender, EventArgs e) { try { if (!loop && !playlistLoop && !random) { outputDevice?.Stop(); } if (playlist.SelectedIndex < playlist.Items.Count - 1) { playlist.SelectedIndex = playlist.SelectedIndex + 1; } else if (playlist.SelectedIndex == playlist.Items.Count - 1) { playlist.SelectedIndex = 0; } if (playlist.SelectedItem != null) { filepath.Text = playlist.SelectedItem.ToString(); if (!loop || !random) { playAsync_Click(sender, e); } } } catch (Exception ex) { toolStripLabel.Text = "Problem z następnym - " + ex.ToString(); } }
public void Load(string filename) { _player?.Stop(); _player?.Dispose(); _reader?.Dispose(); _reader = new AudioFileReader(filename); _player = new WaveOutEvent(); _player.Init(this); }
//stop button, executes stop function(OnPlayBackStopped). public void OnButtonStopClick() { outputDevice?.Pause(); outputDevice?.Stop(); DisposeOfSong(); audioFile = null; isPlaying = false; if (_CurrentSong != null) { MusicQueue.AddSongToPreviousQueue(_CurrentSong); } }
public static void ClearAll() { if (!Initialized) { Main.Log("[AUDIO] Not initialized, cannot clear all!"); return; } foreach (var item in Providers) { item.Value.ClearBuffer(); } Providers.Clear(); IDs.Clear(); Mixer.RemoveAllMixerInputs(); Output.Stop(); Input.StopRecording(); Mixer = null; Output = null; Input = null; maxID = 0; Initialized = false; Main.Log("[AUDIO] Cleared all data, reset."); }
public override void ButtonHandler(bool value) { if (value) { try { player.DeviceNumber = deviceIndex; audioFileStream.Position = 0; player.Play(); } catch (Exception ex) { Console.WriteLine(ex); } } else { try { player.Stop(); } catch (Exception ex) { Console.WriteLine(ex); } } }
public void DisposeScene() { keepPlaying = false; OutputDevice.Stop(); OutputDevice.PlaybackStopped -= SongStopped; audioFile.Seek(0, System.IO.SeekOrigin.Begin); }
public static void Stop() { if (CurrentlyPlaying) { _device.Stop(); } }
/// <summary> /// Stops replay /// </summary> public void StopReplay() { if (_wav != null) { _wav.Stop(); } }
private void button6_Click(object sender, EventArgs e) { try { string filename = MyList.SearchToNext(listBox1.SelectedItem.ToString()); try { listBox1.SelectedIndex += 1; outputDevice.Dispose(); outputDevice = new WaveOutEvent(); audioFile = new AudioFileReader(filename); outputDevice.Init(audioFile); songtrack.Maximum = (int)audioFile.TotalTime.TotalSeconds; songtrack.Value = 0; outputDevice.Play(); timer1.Start(); } catch (ArgumentOutOfRangeException) { outputDevice.Stop(); outputDevice.Dispose(); pictureBox2.Visible = true; return; } } catch (NullReferenceException) { } }
public void PlaySound(string filename) { if (m_player.PlaybackState != PlaybackState.Stopped) { m_delayedAction = () => PlaySound(filename); m_player.Stop(); } else { m_audioFile = new AudioFileReader("Library\\" + filename); //m_audioFile.Skip(); m_player.Init(m_audioFile); m_player.Play(); m_delayedAction = null; } }
private void OnButtonStopClick(object sender, EventArgs e) { if (player != null) { player.Stop(); } }
public void PlayOneSong() { AudioFileReader audioFile = null; WaveOutEvent outputDevice = null; try { string audioFilePath = @"C:\Users\DJTom\OneDrive\Plocha\20201007_hodina\SongsAndVotesSol\Resources\Peter_Nemec_-_Future_Life_OFFICIAL_LYRICS_VIDEO_1.mp3"; audioFile = new AudioFileReader(audioFilePath); outputDevice = new WaveOutEvent(); outputDevice.Init(audioFile); outputDevice.Play(); Console.ReadKey(true); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(true); } finally { if (outputDevice != null) { outputDevice.Stop(); outputDevice.Dispose(); } if (audioFile != null) { audioFile.Close(); audioFile.Dispose(); } } }
private void SynthThread() { WaveOutEvent _waveOutEvent = new WaveOutEvent(); _waveOutEvent.DeviceNumber = -1; _waveOutEvent.DesiredLatency = DesiredLatency; _waveOutEvent.NumberOfBuffers = 2; _waveOutEvent.Init(this); _waveOutEvent.Play(); while (true) { if (_waveOutEvent.DesiredLatency != DesiredLatency) { _waveOutEvent.Stop(); while (_waveOutEvent.PlaybackState != PlaybackState.Stopped) { Thread.Sleep(10); } _waveOutEvent.DesiredLatency = DesiredLatency; _waveOutEvent.Init(this); _waveOutEvent.Play(); } Thread.Sleep(1); } }
private static void Output_PlaybackStopped(object sender, StoppedEventArgs e) { output.Stop(); output.Dispose(); output.Dispose(); wav.Dispose(); }
private static void PlayOnDevice(string fileName, int device) { var waveOut = new WaveOutEvent(); waveOut.DeviceNumber = device; WaveStream reader; if (fileName.EndsWith("mp3")) { reader = new Mp3FileReader(fileName); } else { reader = new WaveFileReader(fileName); } waveOut.Init(reader); waveOut.Play(); while (waveOut.PlaybackState != PlaybackState.Stopped) { Thread.Sleep(20); } waveOut.Stop(); reader.Dispose(); waveOut.Dispose(); }
private void btnStopSound_Click(object sender, RoutedEventArgs e) { if (outputDevice != null) { outputDevice.Stop(); } }
public void Stop() { _outputDevice.Stop(); //Reset Audio file to beginning _audioFile.CurrentTime = new TimeSpan(0, 0, 0); }
/// <summary> /// NIE KURWA JEGO MAĆ RUSZAĆ TEGO. CHUJ WIE JAK TO DZIAŁA, ALE ,,U MNIE DZIAŁO" /// </summary> public static void Stop() { woe.Stop(); Source.Global.PlayerTaskPaused = true; Source.Global.PlaysMusic = false; Source.Global.PlayerTaskStopped = true; }
private void btnDetener_Click(object sender, RoutedEventArgs e) { output.Stop(); btnReproducir.IsEnabled = true; btnPausa.IsEnabled = false; btnDetener.IsEnabled = false; }
public void Stop() { if (player != null) { player.Stop(); } }
public void API(string filePath) { AudioFileReader audioFile = null; WaveOutEvent outputDevice = null; try { audioFile = new AudioFileReader(filePath); outputDevice = new WaveOutEvent(); outputDevice.Init(audioFile); outputDevice.Play(); Console.ReadKey(true); } catch (Exception e) { Console.WriteLine(e.Message); } finally { outputDevice.Stop(); outputDevice.Dispose(); audioFile.Close(); audioFile.Dispose(); } }
public void StopAudio() { if (_waveOut != null && _mp3Reader != null) { _waveOut.Stop(); } }
static void Main() { var player = new WaveOutEvent { NumberOfBuffers = 2, DesiredLatency = 100, }; var trombone = new PinkTromboneSampleProvider(sampleRate: 48000); player.Init(trombone); player.Play(); for (int tone = 0; tone < 24; tone++) { trombone.Thrombone.SetMusicalNote(tone); Thread.Sleep(300); } for (int tone = 22; tone >= 0; tone--) { trombone.Thrombone.SetMusicalNote(tone); Thread.Sleep(300); } Console.WriteLine("Press any key to stop"); Console.ReadKey(); player.Stop(); }
private void Timer_Tick(object sender, EventArgs e) { currentSecond = (int)mp3Reader.CurrentTime.TotalSeconds; lblRealTime.Text = mp3Reader.CurrentTime.ToString("hh':'mm':'ss"); if (currentSecond >= timeEnd) { btnPlay.Visible = true; btnStop.Visible = false; waveOut.Stop(); mp3Reader.Position = 0; mp3Reader.Dispose(); waveOut.Dispose(); timer.Stop(); } }
public void Play(byte[] buffer) { if (waveOutEvent == null) { waveOutEvent = new WaveOutEvent(); waveOutEvent.DeviceNumber = deviceNumber; waveOutEvent.PlaybackStopped += playbackStopped; } else { waveOutEvent.Stop(); } waveOutEvent.Init(new RawSourceWaveStream(new MemoryStream(buffer), new WaveFormat(44100, WaveOut.GetCapabilities(waveOutEvent.DeviceNumber).Channels))); waveOutEvent.Volume = 1; waveOutEvent.Play(); }
public void StopPlayback() { if (outDevice != null) { outDevice.Stop(); } }
private void disposes() { try { track.Text = ""; artist.Text = ""; year.Text = ""; album.Text = ""; label6.Text = ""; cover.Image = null; trackBar1.Value = 0; label2.Text = "00:00"; label3.Text = "00:00"; if (sound != null) { sound.Stop(); sound.Dispose(); sound = null; } if (rd != null) { rd.Dispose(); rd = null; } if (reader != null) { reader.Dispose(); reader = null; } } catch (Exception) { } }
/// <summary> /// Closes the session. /// </summary> /// <param name="reason">Reason for the closure.</param> public override void Close(string reason) { if (!_isClosed) { _isClosed = true; base.OnRtpPacketReceived -= RtpPacketReceived; _waveOutEvent?.Stop(); if (_waveInEvent != null) { _waveInEvent.DataAvailable -= LocalAudioSampleAvailable; _waveInEvent.StopRecording(); } _audioStreamTimer?.Dispose(); if (_testPatternVideoSource != null) { _testPatternVideoSource.SampleReady -= LocalVideoSampleAvailable; _testPatternVideoSource.Stop(); _testPatternVideoSource.Dispose(); } // The VPX encoder is a memory hog. _vpxDecoder.Dispose(); _imgConverter.Dispose(); _vpxEncoder?.Dispose(); _imgEncConverter?.Dispose(); base.Close(reason); } }
//Create a disposable Sound Player void PlaySound() { using (WaveOutEvent tempWave = new WaveOutEvent()) { tempWave.DeviceNumber = outputDeviceID; //Set the Output Device WaveFileReader reader = null; reader = new WaveFileReader(filepath); WaveChannel32 inputStream = new WaveChannel32(reader); inputStream.PadWithZeroes = false; tempWave.Init(reader); tempWave.Volume = volume; tempWave.Play(); while (tempWave.PlaybackState != PlaybackState.Stopped) { //Wait and continue when finished if (stop) { tempWave.Stop(); } } AudioMixer.RemoveSpeaker(this); //Remove Speaker from lists reader.Dispose(); //Dispose reader tempWave.Dispose(); //Dispose wave if (deleteFile) //Delete file if deleteFile is true { File.Delete(filepath); //Delete used and created file } } }