protected virtual void btn_play_Click(object sender, RoutedEventArgs e) { var item = SelectedSongs.FirstOrDefault() ?? Items.OfType <SongViewModel>().FirstOrDefault(); if (item == null) { return; } var location = item.Song.DownloadState == "complete" ? item.Song.FilePath : item.Song.UrlMp3; if (string.IsNullOrEmpty(location)) { return; } if (Mp3Player.GetPlayOrPause(item.Id)) { if (!PlayList.Contains(item)) { PlayList.NeedsRefresh(); PlayList.Refresh(Items.OfType <SongViewModel>()); } else if (isMultiSelect(this)) { PlayList.NeedsRefresh(); PlayList.Refresh(SelectedSongs); } } Mp3Player.Play(location, item.Id); ActionBarService.Refresh(); }
private void btnPlay_Click(object sender, RoutedEventArgs e) { if (songLoaded) { mp3Player.Play(); timer.Start(); } }
private static void PlayEffect() { try { string dir = "sounds/effects"; if (!Directory.Exists(dir)) { return; } var files = Directory.GetFiles(dir).Where(f => f.EndsWith(".mp3")).ToArray(); if (files.Length > 0) { Task.Run(() => { effectPlayer.Load(files.ChooseRandomly()); effectPlayer.Play(); Thread.Sleep(200); //don't want it to always do the same action always. if (rand.Next(0, 10) % 2 == 0) { if (isMp3) { LowerVolume(mp3Player, 5, 150); } } PlayAsync(); //don't want it to always do the same action always. if (rand.Next(0, 10) % 2 == 0) { effectPlayer.Load(files.ChooseRandomly()); effectPlayer.Play(); } }); } } catch { } }
private void Playbtn_Click(object sender, EventArgs e) { try { if (mp3.Play() == 1) { MessageBox.Show("No song loaded"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "cant play file", MessageBoxButtons.OK); } }
public static async void PlayAsync() { if (Settings.GetSettings().MusicFiles.Count == 0 || !Settings.GetSettings().MusicOn) { return; } try { if (paused) { await ResumeAsync(); return; } if (Playing) { return; } var musicFile = Settings.GetSettings().MusicFiles.ChooseRandomly(); string file = musicFile.FileName; string path = musicFile.FilePath; byte[] buffer = null; if (file.ToLower().EndsWith(".mp3")) { isMp3 = true; await Task.Run(() => { mp3Player.Load(path); ///buffer = await ConvertMp3ToWaveAsync(path); mp3Player.Play(); }); Playing = true; return; } isMp3 = false; buffer = File.ReadAllBytes(path); player.Load(buffer); player.Play(); Playing = true; } catch (Exception ex) { Playing = false; } }
private void Speek_OnExecute(string audioPath) { if (File.Exists(audioPath)) { if (_mp3Player == null) { _mp3Player = new Mp3Player(); } else { _mp3Player.Pause(); } _mp3Player.FilePath = audioPath; _mp3Player.Play(); } }
private void OnAppbarPlayAndPauseClick(Object sender, EventArgs args) { if (!isPlayClicked) { Mp3Player.Play(); appbarPlayAndPauseButton.IconUri = new Uri("Images/appbar.transport.pause.rest.png", UriKind.Relative); appbarPlayAndPauseButton.Text = "Play"; isPlayClicked = true; } else { Mp3Player.Pause(); appbarPlayAndPauseButton.IconUri = new Uri("Images/appbar.transport.play.rest.png", UriKind.Relative); appbarPlayAndPauseButton.Text = "Pause"; isPlayClicked = false; } }
public void ResumeMix() => _mp3Player?.Play();
public void PlayMix(string fileName) { _mp3Player = new Mp3Player(fileName); _mp3Player.Play(); }
private void button1_Click(object sender, EventArgs e) { _mp3Player.Play(); }
/// <summary> /// Resumes the playback /// </summary> public void Play() { player.Play(); }
void IMp3Player.Play() { mMp3Player.Play(); }