/// <summary> /// This method is executed when the selected song in playlist is /// changed. /// </summary> /// <param name="sender">The Playlist instance</param> /// <param name="e">Event parameters</param> private async void Playlist_SelectedSongChanged(object sender, EventArgs e) { this.Player?.Stop(); #region Error checking //If the playlist is empty, we need to attach a NULL-playback //manager and prevent any other actions. if (this.Playlist.CurrentSongInfo == null) { this.AttachPlayer(PlaybackFactory.NullPlayback(this.Player.Volume)); return; } #endregion IPlaybackManager NewPlaybackManager = null; try { this.viewModel.LyricsReader = null; this.viewModel.Lyrics = "Zene megnyitása..."; NewPlaybackManager = await PlaybackFactory.LoadMedia(this.Playlist.CurrentSongInfo); } catch (Exception ex) { if (ex is IOException || ex is NotSupportedException) { new Toast(App.Name) { Title = "Hoppá...", Content = "Ezt a fájlt nem tudjuk megnyitni.", Image = TomiSoft.MP3Player.Properties.Resources.AbstractAlbumArt }.Show(); } return; } this.AttachPlayer(NewPlaybackManager); this.Player?.Play(); //Load lyrics this.OpenLyricsAsync(this.Playlist.CurrentSongInfo); }
private void button1_Click(object sender, EventArgs e) { //======================================================================================= //Clear textBox tbOutput.Clear(); //return Selected radiobutton index int rbIndex = CheckSelectedRadioButton(WinForm); if (rbIndex != 0) { MobilePhone simCorpMobile = SimCorpMobile.Instance; //create class with DI PlaybackFactory playbackFactory = new PlaybackFactory(WinForm); //create component class simCorpMobile.Playback = playbackFactory.Create(rbIndex).MobileComponent as IPlayback; //show playing device in textbox simCorpMobile.Play(); } //======================================================================================= }
/// <summary> /// This method is executed when one or more files were /// dropped to the window. /// </summary> /// <param name="sender">The sender object's instance</param> /// <param name="e">Event parameters</param> private void Window_Drop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] Files = (string[])e.Data.GetData(DataFormats.FileDrop); this.Playlist.Clear(); foreach (string File in Files) { if (PlaybackFactory.IsSupportedMedia(File)) { this.Playlist.Add(new BassSongInfo(File)); } } if (this.Playlist.Count > 0) { this.Playlist.MoveTo(0); } } }
public bool IsSupportedMedia(string Source) { return(PlaybackFactory.IsSupportedMedia(Source)); }