private void Stop() { _audioPlayback?.Stop(); TrackBarValue = 0.0f; TrackBarString = "00:00:00 / 00:00:00"; _trackBarTimer.Stop(); }
public bool Stop() { if (!audioPlayback.IsPlaying) { return(false); } audioPlayback.Stop(); // The rest will be updated by the PlaybackStopped callback. return(true); }
public void StopSelectedAudioFile() { //Stop the selected audio file from playing //if(AudioControl != null) //{ // AudioControl.StopAudio(); //} if (audioPlayback != null) { audioPlayback.Stop(); } }
public void Stop() { if (Animating) { Animating = false; Paused = false; Zoom = _oldZoom; Camera.SetPosition(_oldPos); _track.RiderState.Reset(_track.Start, _track); Camera.ViewPosition = _oldPos; Camera.AimPosition = Camera.ViewPosition; game.Scheduler.UpdatesPerSecond = 40; foreach (var v in ActiveTriggers) { v.Reset(); } ActiveTriggers.Clear(); if (game.EnableSong) { AudioPlayback.Stop(); } var canvas = game.Canvas; var buttons = canvas.FindChildByName("buttons"); buttons.FindChildByName("pause").IsHidden = true; buttons.FindChildByName("start").IsHidden = false; var slider = canvas.FindChildByName("timeslider"); slider.IsHidden = true; game.Canvas.FindChildByName("labeliterations").IsHidden = true; game.Canvas.FindChildByName("vslider", true).IsHidden = false; canvas.FindChildByName("btnfastforward").IsHidden = true; canvas.FindChildByName("btnslowmo").IsHidden = true; //incase recording mode was enabled at the start. There's a risk it was disabled during playback //if that's the case checking game.RecordingMode would fail but controls would remain invisible. //instead, we just by default ensure visibility { buttons.IsHidden = false; game.Canvas.FindChildByName("fps", true).IsHidden = false; game.Canvas.FindChildByName("ppf", true).IsHidden = false; game.Canvas.FindChildByName("labelplayback", true).IsHidden = false; game.Canvas.FindChildByName("trackname", true).IsHidden = false; } game.Invalidate(); } }
public MainViewModel() { if (IsInDesignMode) { // Code runs in Blend --> create design time data. Title = _title; NeteaseUrl = "http://music.163.com/#/my/m/music/playlist?id=6435531"; SongCollection.Add(new Song() { Title = new Title("Clover Heart's"), Artists = new Artists(new string[] { "榊原ゆい", "榊原ゆい" }), Album = new Album("Boommmmm", "http://p4.music.126.net/n189nEFRefNaucKD8akNQw==/7886796906449604.jpg"), }); SongCollection.Add(new Song() { Title = new Title("Clover Heart's"), Artists = new Artists(new string[] { "榊原ゆい" }), Album = new Album("Boommmmm", "http://p4.music.126.net/n189nEFRefNaucKD8akNQw==/7886796906449604.jpg"), }); SongCollection.Add(new Song() { Title = new Title("Clover Heart's"), Artists = new Artists(new string[] { "榊原ゆい" }), Album = new Album("Boommmmm", "http://p4.music.126.net/n189nEFRefNaucKD8akNQw==/7886796906449604.jpg"), }); SelectedSong = SongCollection.First(); } else { // Code runs "for real" Title = _title; NeteaseUrl = "http://music.163.com/playlist?id=6435531"; Progress = 0; audioPlayback = new AudioPlayback(); audioPlayback.Volume = Volume; audioPlayback.EndCallback += (handle, channel, data, user) => { int index = -1; if ((index = SongCollection.IndexOf(CurrentPlaySong)) != -1) { ListenCommand.Execute(SongCollection.ElementAt((index + 1) % SongCollection.Count)); } else { audioPlayback.Stop(); NowPlaying = ""; CurrentPlaySong.PlayProgress = 0; CurrentPlaySong.PlayStatus = PlayStatus.Play; timer.Enabled = false; timer.Stop(); } }; timer.Tick += (sender, args) => { Title = string.Format("{0}/{1} - {2}", audioPlayback.CurrentLength, audioPlayback.TotalLength, _title); RaisePropertyChanged("Title"); CurrentPlaySong.PlayProgress = audioPlayback.Progress; }; GetSongsCommand = new RelayCommand(async() => { if (string.IsNullOrWhiteSpace(NeteaseUrl)) { return; } var id = ""; var urlType = ""; var reg = new Regex(@".*/(.*?)\?id=(\d*)").Match(NeteaseUrl); if (reg.Success) { urlType = reg.Groups[1].Value; id = reg.Groups[2].Value; SongCollection.Clear(); switch (urlType) { case "album": foreach (var song in await NeteaseUtil.GetSongsFromAlbum(id)) { SongCollection.Add(song); RaisePropertyChanged("TotalCount"); } break; case "artist": foreach (var song in await NeteaseUtil.GetSongsFromArtist(id)) { SongCollection.Add(song); RaisePropertyChanged("TotalCount"); } break; case "playlist": foreach (var song in await NeteaseUtil.GetSongsFromPlaylist(id)) { SongCollection.Add(song); RaisePropertyChanged("TotalCount"); } break; case "song": foreach (var song in await NeteaseUtil.GetSongDetail(id)) { SongCollection.Add(song); RaisePropertyChanged("TotalCount"); } break; } } else { SongCollection.Clear(); foreach (var song in await NeteaseUtil.SearchSongs(NeteaseUrl)) { SongCollection.Add(song); RaisePropertyChanged("TotalCount"); } } }); PlaylistDownloadCommand = new RelayCommand <Song>((song) => { SelectedSong = song; if (string.IsNullOrWhiteSpace(SongTrackUrl)) { return; } var downloader = new DownloadUtils(); downloader.DownloadProgressChanged += (sender, args) => { song.DownProgress = args.ProgressPercentage; BytesReceived = args.BytesReceived.ToString(); TotalBytesToReceive = args.TotalBytesToReceive.ToString(); }; downloader.DownloadFileCompleted += (sender, args) => { if (DownloadNext) { int index = -1; if ((index = SongCollection.IndexOf(song)) != -1 && index + 1 < SongCollection.Count) { PlaylistDownloadCommand.Execute(SongCollection.ElementAt(index + 1)); } } else { BytesReceived = "0"; TotalBytesToReceive = "0"; } }; downloader.Get(SongTrackUrl, Path.Combine("music", FileUtils.GetSafeFileName(song.SongFileName))); }); ListenCommand = new RelayCommand <Song>((song) => { SelectedSong = song; if (string.IsNullOrWhiteSpace(SongTrackUrl)) { return; } if (song.PlayStatus == PlayStatus.Play) { if (CurrentPlaySong != null && CurrentPlaySong != song) { audioPlayback.Stop(); CurrentPlaySong.PlayProgress = 0; CurrentPlaySong.PlayStatus = PlayStatus.Play; } audioPlayback.Load(SongTrackUrl); audioPlayback.Play(); CurrentPlaySong = song; NowPlaying = string.Format("Now Playing {0} - {1}", song.Artists, song.Title); timer.Enabled = true; timer.Start(); song.PlayProgress = 0; song.PlayStatus = PlayStatus.Stop; } else { audioPlayback.Stop(); NowPlaying = ""; song.PlayStatus = PlayStatus.Play; song.PlayProgress = 0; timer.Enabled = false; timer.Stop(); } }); OpenUrlCommand = new RelayCommand <string>((link) => { System.Diagnostics.Process.Start(link); }); CopyUrlCommand = new RelayCommand <string>((link) => { Clipboard.SetText(link); }); WindowClosing = new RelayCommand(() => { Properties.Settings.Default.Save(); }); } }