public MainWindow(SovndClient client, ChannelDirectory channels, IPlayerFactory playerFactory, ISettingsProvider settings, Scrobbler scrobbler) { InitializeComponent(); toast = new Toast(); toast.Show(); _scrobbler = scrobbler; _client = client; _playerFactory = playerFactory; _settings = settings.GetSettings(); AllowDrop = true; channelbox.ItemsSource = channels.channels; PreviewDragOver += OnPreviewDragEnter; PreviewDragEnter += OnPreviewDragEnter; DragEnter += OnPreviewDragEnter; DragOver += OnPreviewDragEnter; Drop += OnDrop; Loaded += (_, __) => { BindingOperations.EnableCollectionSynchronization(channels.channels, channels.channels); App.WindowHandle = new WindowInteropHelper(this).Handle; synchronization = SynchronizationContext.Current; _client.Run(); if (!string.IsNullOrWhiteSpace(_settings.LastChannel)) { _player = _playerFactory.CreatePlayer(_settings.LastChannel); _client.SubscribeToChannel(_settings.LastChannel); SetupChannel(); Logging.Event("Switched to previously set channel"); } }; Closed += (_, __) => { _client.Disconnect(); Spotify.ShutDown(); Process.GetCurrentProcess().Kill(); // TODO That's really inelegant }; }
private string GetAlbumArtLink(libspotify.sp_image_size artSize = libspotify.sp_image_size.SP_IMAGE_SIZE_SMALL) { var image = Spotify.GetAlbumArtLink(_albumPtr, artSize); if (image == null) { image = Spotify.GetAlbumArtLink(_albumPtr, libspotify.sp_image_size.SP_IMAGE_SIZE_SMALL); } if (image == null) { image = Spotify.GetAlbumArtLink(_albumPtr, libspotify.sp_image_size.SP_IMAGE_SIZE_NORMAL); } if (image == null) { image = Spotify.GetAlbumArtLink(_albumPtr, libspotify.sp_image_size.SP_IMAGE_SIZE_LARGE); } if (image == null) { throw new Exception("Couldn't get art link"); } return(image); }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { string text = tbSearch.Text; if (!string.IsNullOrWhiteSpace(text)) { if (searchToken != null) { searchToken.Cancel(); } searchToken = new CancellationTokenSource(); var token = searchToken.Token; Task.Run(() => { var search = Spotify.GetSearch(text); if (search == null) { return; } var tracks = from trackPtr in search.TrackPtrs select new Track(trackPtr); synchronization.Send((_) => lbPlaylist.ItemsSource = tracks.Take(25), null); }, token); } else { if (searchToken != null) { searchToken.Cancel(); } BindToPlaylist(); Logging.Event("Searched"); } }
public string GetAlbumArtLink() { return(Spotify.GetAlbumArtLink(AlbumPtr)); }