示例#1
0
        private void PlayToggleButton_Click(object sender, RoutedEventArgs e)
        {
#if NAUDIO
            if (PlayerStream.PlaybackState == PlaybackState.Stopped || PlayerStream.PlaybackState == PlaybackState.Paused)
            {
                PlayToggleButton.Content = "\uE769";
                PlayerStream.Play();
            }
            else
            {
                PlayToggleButton.Content = "\uE768";
                PlayerStream.Pause();
            }
#else
            if (GetMediaState(player) == MediaState.Stop || GetMediaState(player) == MediaState.Pause)
            {
                PlayToggleButton.Content = "\uE769";
                player.Play();
            }
            else
            {
                PlayToggleButton.Content = "\uE768";
                player.Pause();
            }
#endif
        }
示例#2
0
        public Form1()
        {
            InitializeComponent();
            listSongs_Main = songDAO.loadAllSongs();



            listSongs_Search = new List <SongDTO>();
            string fol_Dir = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

            string[] tokens = fol_Dir.Split(new[] { "\\Music" }, StringSplitOptions.None);
            SONG_PATH                 = tokens[0] + "\\Music\\MusicFol\\";
            SONG_IMAGE_PATH           = tokens[0] + "\\Music\\SongImageFol\\";
            ALBUM_IMAGE_PATH          = tokens[0] + "\\Music\\AlbumImageFol\\";
            ARTIST_IMAGE_PATH         = tokens[0] + "\\Music\\ArtisImageFol\\";
            PLAYLIST_IMAGE_PATH       = tokens[0] + "\\Music\\PlaylistImageFol\\";
            LASTEST_OPEN_DETAILS_PATH = tokens[0] + "\\Music\\latestDetails.txt";
            GrammarControl grammarControl = new GrammarControl();

            recognitionEngine.SetInputToDefaultAudioDevice();
            loadGrammar(grammarControl.getSimpleGrammar());
            fisrt = false;
            defaultPlaybackDevice.Volume = 20;
            soundControl.Value           = 20;
            listSongs_Search             = listSongs_Main;
            loadSongLabel();
            setUpScrollBar();

            Mp3FileReader mp3Reader = new Mp3FileReader(SONG_PATH + listSongs_Main[songIndex].LinkOpen);

            player.Init(mp3Reader);
            player.Pause();
        }
示例#3
0
        private void PlayAndPause_Click(object sender, EventArgs e)
        {
            Button button = sender as Button;

            if (_waveOut.PlaybackState == PlaybackState.Playing)
            {
                _waveOut.Pause();

                button.Text = _playSymbol;
            }
            else if (_waveOut.PlaybackState == PlaybackState.Paused)
            {
                _waveOut.Play();

                button.Text = _pauseSymbol;
            }
            else if (_waveOut.PlaybackState == PlaybackState.Stopped)
            {
                try
                {
                    SetSongToPlay(_playingSongNumber);
                    _waveOut.Play();
                }
                catch { }

                button.Text = _pauseSymbol;
            }
        }
示例#4
0
 public void Pause()
 {
     if (_waveOut != null)
     {
         _waveOut.Pause();
         _isPlaying(false);
         _playbackState = StreamingPlaybackState.Paused;
     }
 }
示例#5
0
 //stop button, executes stop function(OnPlayBackStopped).
 public void OnButtonStopClick()
 {
     outputDevice?.Pause();
     outputDevice?.Stop();
     DisposeOfSong();
     audioFile = null;
     isPlaying = false;
     if (_CurrentSong != null)
     {
         MusicQueue.AddSongToPreviousQueue(_CurrentSong);
     }
 }
示例#6
0
 private void pauseplay()
 {
     if (sound != null)
     {
         if (sound.PlaybackState == PlaybackState.Playing)
         {
             sound.Pause();
         }
         else if (sound.PlaybackState == PlaybackState.Paused)
         {
             sound.Play();
         }
     }
 }
示例#7
0
文件: Form1.cs 项目: syanick/Delay
        private void InitializeAudio()
        {
            input.Dispose();
            output.Dispose();
            output              = new WaveOutEvent();
            input               = new WaveInEvent();
            input.DeviceNumber  = inputSelector.SelectedIndex;
            output.DeviceNumber = outputSelector.SelectedIndex;


            input.WaveFormat = waveformat;

            input.DataAvailable += new EventHandler <WaveInEventArgs>(DataAvailable);
            filter = new BiQuadFilter[waveformat.Channels];
            for (int i = 0; i < filter.Length; i++)
            {
                filter[i] = BiQuadFilter.LowPassFilter(waveformat.SampleRate, waveformat.SampleRate / 2, (float)Q);
            }

            output.Init(buffer);
            output.Pause();
            try
            {
                input.StartRecording();
                recording = true;
            }
            catch
            {
            }
        }
 public void Pause()
 {
     if (_outputDevice.PlaybackState == PlaybackState.Playing)
     {
         _outputDevice.Pause();
     }
 }
示例#9
0
        private void ButtonPlayPause_Click(object sender, EventArgs e)
        {
            if (Music.Count != 0)
            {
                if (MusicState == MusicState.Pause)
                {
                    if (CurrentPlayingMusicIndex == 0 && WaveOutEvent == null)
                    {
                        MusicInitialize(Music[CurrentPlayingMusicIndex]);
                    }
                    else
                    {
                        WaveOutEvent.Play();

                        MusicState = MusicState.Play;
                        ButtonPlayPause.BackgroundImage    = Properties.Resources.Pause;
                        PlayAndPauseToolStripMenuItem.Text = "Pause";
                    }
                }
                else if (MusicState == MusicState.Play)
                {
                    WaveOutEvent.Pause();

                    MusicState = MusicState.Pause;
                    ButtonPlayPause.BackgroundImage    = Properties.Resources.Play;
                    PlayAndPauseToolStripMenuItem.Text = "Play";
                }
            }
            else
            {
                OpenFilesToolStripMenuItem_Click(sender, e);
            }
        }
示例#10
0
 //start, and pause and resume button.
 public void OnButtonPlayClick(object sender, EventArgs args)
 {
     if (!isPlaying)
     {
         //for unittesting.
         //if (audioFile == null)
         //{
         //    audioFile = new AudioFileReader("67.mp3");
         //    outputDevice.Init(audioFile);
         //}
         try
         {
             outputDevice.Play();
             isPlaying = true;
         } catch (Exception)
         {
             Console.WriteLine("No song to play");
         }
     }
     else
     {
         outputDevice.Pause();
         isPlaying = false;
     }
 }
示例#11
0
 public void Pause()
 {
     if (m_wo != null)
     {
         m_wo.Pause();
     }
 }
示例#12
0
 private void OnButtonPauseClick(object sender, EventArgs e)
 {
     if (player != null)
     {
         player.Pause();
     }
 }
示例#13
0
        // Pauses and plays the current song
        private void songControlButton_Click(object sender, EventArgs e)
        {
            if (currentSong != null)
            {
                if (cbtnState == ControlButtonState.Play)
                {
                    if (currentSP.PlaybackState == PlaybackState.Paused)
                    {
                        currentSP.Play();
                    }
                    else if (currentSP.PlaybackState == PlaybackState.Stopped)
                    {
                        PlaySong(currentSong);
                    }

                    ChangeControlButtonState(ControlButtonState.Stop);
                    SongTimer.Enabled = true;
                }
                else
                {
                    currentSP.Pause();
                    ChangeControlButtonState(ControlButtonState.Play);
                    SongTimer.Enabled = false;
                }
            }
        }
示例#14
0
        private void button3_Click(object sender, EventArgs e)
        {
            var mf = new MediaFoundationReader(currentFile);

            if (playing)
            {
                wo.Pause();
                button3.Text = "Play";
                playing      = false;
            }
            else
            {
                {
                    try
                    {
                        wo.Init(mf);
                    }
                    catch
                    {
                    }
                    wo.Play();
                    if (wo.PlaybackState == PlaybackState.Playing)
                    {
                        button3.Text = "Pause";
                    }
                    playing = true;
                }
            }
        }
示例#15
0
 private void but_Pause_Click(object sender, EventArgs e)
 {
     but_Pause.ForeColor = Color.Blue;
     waveOut.Pause();
     trackUpdater.Stop();
     Console.WriteLine("Staph at: {0:t} at byte: {1}", wove.CurrentTime, wove.Position);
 }
示例#16
0
 public int Play(int index = -1, bool slowly = false)
 {
     if (index < 0 || PlayList.Count == 0)
     {
         return(-1);
     }
     if (PlayList.Count <= index)
     {
         index = 0;
     }
     audioFileReader = new AudioFileReader(PlayList[index]);
     if (outputDevice != null)
     {
         outputDevice.Pause();
     }
     outputDevice = new WaveOutEvent();
     outputDevice.PlaybackStopped += OutputDevice_PlaybackStopped;
     outputDevice.Init(audioFileReader);
     if (slowly)
     {
         float _volume = outputDevice.Volume;
         outputDevice.Volume = 0;
         RunSlowly(_volume);
     }
     outputDevice.Play();
     PlayListIndex = index;
     return(PlayListIndex);
 }
示例#17
0
        private void button6_Click(object sender, EventArgs e)
        {
            if (outputDevice != null && outputDevice.PlaybackState == PlaybackState.Playing)
            {
                outputDevice.Pause();
                timer.Stop();
            }
            else if (outputDevice != null && outputDevice.PlaybackState == PlaybackState.Paused)
            {
                outputDevice.Play();
                timer.Start();
            }
            else
            {
                outputDevice                   = new WaveOutEvent();
                audioFile                      = new AudioFileReader(LastSavedFile);
                trackbarPosition.Maximum       = (int)audioFile.Length;
                trackbarPosition.TickFrequency = (int)(audioFile.Length / 100);
                outputDevice.PlaybackStopped  += OnPlaybackStopped;

                outputDevice.Init(audioFile);
                timer.Start();
                outputDevice.Play();
            }
        }
示例#18
0
            private void PlayInLoopAsync_CallBack()
            {
                while (_loopPlaying)
                {
                    switch (Emulator.Instance.CurrentState)
                    {
                    case Emulator.TCurrentState.PAUSED:
                        _outputDevice.Stop();
                        break;

                    case Emulator.TCurrentState.STOPPED:
                        _loopPlaying = false;
                        break;

                    default:
                        _outputDevice.Play();
                        _audioFileReader.Position = 0;
                        break;
                    }

                    if (Emulator.Instance.CurrentState == Emulator.TCurrentState.PAUSED)
                    {
                        _outputDevice.Pause();
                    }
                }
            }
示例#19
0
 private void pauseButton_Click(object sender, EventArgs e)
 {
     if (init)
     {
         waveOut.Pause();
     }
 }
 public void Pause()
 {
     if (player != null)
     {
         player.Pause();
     }
 }
示例#21
0
        protected void buttonPlay_Click(object sender, EventArgs e)
        {
            Button button = (sender as Button);

            if (button.Text == ">")
            {
                if (markerPoint.X < Math.Max(splitP1.X, splitP2.X))
                {
                    mp3Reader.CurrentTime = TimeSpan.FromSeconds(CursorTime());
                }
                else
                {
                    mp3Reader.CurrentTime = TimeSpan.FromSeconds(SplitStartTimeFromSecond());
                }
                button.Text = "||";
                timer.Start();
                player.Play();
            }
            else
            {
                timer.Stop();
                button.Text = ">";
                player.Pause();
            }
        }
示例#22
0
 /// <summary>
 /// The BtnPause_Click.
 /// </summary>
 /// <param name="sender">The sender<see cref="object"/>.</param>
 /// <param name="e">The e<see cref="EventArgs"/>.</param>
 private void BtnPause_Click(object sender, EventArgs e)
 {
     if (wo.PlaybackState != PlaybackState.Paused)
     {
         wo.Pause();
     }
 }
示例#23
0
 public void PausePlayback()
 {
     if (outDevice != null)
     {
         outDevice.Pause();
     }
 }
示例#24
0
 private void playButton_Click(object sender, EventArgs e)
 {
     coverAndTitle();
     if (musicIsPlaying == true)
     {
         outputDevice.Pause();
         timerOfPlayback.Stop();
         playButton.Text         = "";
         musicIsPlaying          = false;
         timerOfPlayback.Enabled = false;
     }
     else if (playButton.Text == "")
     {
         outputDevice.Play();
         timerOfPlayback.Start();
         playButton.Text         = "";
         musicIsPlaying          = true;
         timerOfPlayback.Enabled = true;
     }
     else if (fileReader != null && outputDevice != null)
     {
         outputDevice.Play();
         timerOfPlayback.Stop();
         musicIsPlaying          = true;
         playButton.Text         = "";
         timerOfPlayback.Enabled = true;
     }
 }
示例#25
0
        // 再生の状態により、再生開始・一時停止をトグルに切り替える。
        private void playState()
        {
            Console.WriteLine("PlayState={0}   position={1}", outputDevice.PlaybackState, audioFile.Position);
            // 選曲後の処理
            switch (outputDevice.PlaybackState)
            {
            case PlaybackState.Stopped:                              //ファイルが読み込まれてまだ一度も再生されていない場合

                label3.Text = new TimeSpan(0, 0, length).ToString(); //音源の長さ(時間)を表示

                if (currentPosition >= audioFile.Length)
                {
                    currentPosition = 0;
                }
                // 現在の位置を代入
                audioFile.Position = currentPosition;

                timer1.Start();

                outputDevice.Init(audioFile);
                outputDevice.Play();
                iPlayAll         = true;
                playButton.Image = Properties.Resources.pause;
                break;

            case PlaybackState.Paused:    //一時停止時の場合
                outputDevice.Dispose();
                audioFile.Position = currentPosition;
                outputDevice.Init(audioFile);

                timer1.Start();

                outputDevice.Play();
                iPlayAll = true;

                playButton.Image = Properties.Resources.pause;
                break;

            case PlaybackState.Playing:    //再生中の場合
                outputDevice.Pause();
                currentPosition  = audioFile.Position;
                iPlayAll         = false;
                playButton.Image = Properties.Resources.play100_100;

                break;
            }
        }
示例#26
0
 private void Pause(object sender, RoutedEventArgs e)
 {
     if (outputDevice.PlaybackState == PlaybackState.Paused)
     {
         return;
     }
     outputDevice.Pause();
 }
示例#27
0
 public void PauseAudio()
 {
     if (_device == null)
     {
         return;
     }
     _device.Pause();
 }
 private void ButtonPause_Click(object sender, EventArgs e)
 {
     pictureBoxCover.Image = Properties.Resources.pause;
     outputDevice.Pause();
     buttonPause.Enabled = false;
     buttonPlay.Enabled  = true;
     buttonStop.Enabled  = true;
 }
示例#29
0
 private void _viewPlayer_Pause(object sender, EventArgs e)
 {
     audioTimer.Stop();
     if (outputDevice != null)
     {
         outputDevice.Pause();
     }
 }
示例#30
0
            private void PlayAudioThread(string filePath, IProgress <AudioTrack> progress, CancellationToken ct)
            {
                try
                {
                    using (WaveOutEvent wout = new WaveOutEvent())
                        using (AudioFileReader afr = new AudioFileReader(filePath))
                        {
                            wout.Init(afr);
                            wout.Play();
                            wout.Volume = volume;
                            AudioTrack track = new AudioTrack()
                            {
                                currentTime = TimeSpan.Zero,
                                totalTime   = afr.TotalTime,
                                progress    = 0
                            };

                            while (wout.PlaybackState != PlaybackState.Stopped && !ct.IsCancellationRequested)
                            {
                                if (paused)
                                {
                                    wout.Pause();
                                    Thread.Sleep(1000);
                                }
                                else if (wout.PlaybackState == PlaybackState.Paused)
                                {
                                    wout.Play();
                                }
                                else
                                {
                                    wout.Volume = volume;
                                    progress.Report(track);
                                    track.currentTime = afr.CurrentTime;
                                    track.progress    = (int)Math.Round
                                                        (
                                        (double)(afr.CurrentTime.TotalSeconds / afr.TotalTime.TotalSeconds) * 100d
                                                        );
                                    Thread.Sleep(200);
                                }
                            }
                            wout.Stop();
                            if (ct.IsCancellationRequested)
                            {
                                progress.Report(AudioTrack.empty);

                                ct.ThrowIfCancellationRequested();
                            }
                            else
                            {
                                progress.Report(track);
                            }
                        }
                }
                catch (Exception e)
                {
                    throw new OperationCanceledException(e.ToString());
                }
            }