private void MainForm_Load(object sender, EventArgs e) { spotControl = new SpotifyController(nowPlayingLabel, playMusicToolStripMenuItem); stopButton.Enabled = false; blacklistArtistButton.Enabled = false; blacklistSongButton.Enabled = false; }
public void TestIndex() { var controller = new SpotifyController(); //Arrange var result = controller.Index() as ViewResult; //Act Assert.AreEqual("Index", result.ViewName); //Verify }
protected override void OnFormClosing(FormClosingEventArgs e) { SpotifyController.ShutDown(); playbackManager.Dispose(); _trayIcon.Visible = false; // remove tray icon base.OnFormClosing(e); }
private List <PlaylistContainer.PlaylistInfo> LoadUserPlaylists() { string exceptionMessage = ""; try { return(SpotifyController.GetAllSessionPlaylists()); } // done this way so that we can recursively send this method on if the user chooses to retry catch (Exception ex) { exceptionMessage = ex.Message; } // handle problems - display dialog to user giving them a chance to retry this operation var dialog = MessageBox.Show(StringStore.ErrorDuringLoad + exceptionMessage + "\r\n\r\n" + StringStore.SelectRetryToTryAgainOrCancelToQuit, StringStore.ErrorDuringLoad, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (dialog == DialogResult.Retry) { return(LoadUserPlaylists()); } else { // user has cancelled loading playlists and chosen to exit this.Close(); return(null); } }
public SpotifyControllerTest() { _localApi = Substitute.For <ISpotifyLocalApi>(); _spotifyWebApi = Substitute.For <ISpotifyWebApi>(); _nativeApi = Substitute.For <ISpotifyNativeApi>(); _log = Substitute.For <ILog>(); _spotifyController = new SpotifyController(_log, _localApi, _spotifyWebApi, _nativeApi); }
public static void pauseSpotify(ref Queue <float> otherSoundQueue, ref Queue <float> spotifySoundQueue, ref int spotifyQueueSize, ref int currentQueueSize, ref int ticksInactive, ref int tickDelay) { SpotifyController.pausePlay(); QueueControl.fillQueuesAfterPause(ref otherSoundQueue, ref spotifySoundQueue, ref spotifyQueueSize, ref currentQueueSize); tickDelay = 2; ticksInactive = Configuration.TICKS_BEFORE_START; }
private void LoadArtist(BufferItem item) { ArtistBufferItem abi = item as ArtistBufferItem; _output.OutputMessage(StringStore.LoadingArtistAlbums, false); buffers.Add(new ArtistBufferList(abi.Model.Name)); buffers.CurrentListIndex = buffers.Count - 1; var artistBuffer = buffers.CurrentList; _output.OutputMessage(artistBuffer.ToString(), false); var albums = SpotifyController.GetArtistAlbums(abi.Model.ArtistPtr).ToList(); _output.OutputMessage(String.Format("{0} {1}", albums.Count, StringStore.SearchResults), false); albums.ForEach(a => { artistBuffer.Add(new AlbumBufferItem(new Album(a))); }); }
private void LoadAlbum(BufferItem item) { AlbumBufferItem abi = item as AlbumBufferItem; _output.OutputMessage(StringStore.LoadingAlbum, false); buffers.Add(new AlbumBufferList(abi.Model.Name)); buffers.CurrentListIndex = buffers.Count - 1; var albumBuffer = buffers.CurrentList; _output.OutputMessage(albumBuffer.ToString(), false); var tracks = SpotifyController.GetAlbumTracks(abi.Model.AlbumPtr).ToList(); _output.OutputMessage(String.Format("{0} {1}", tracks.Count, StringStore.TracksLoaded), false); tracks.ForEach(t => { albumBuffer.Add(new TrackBufferItem(new Track(t))); }); }
private void LoadPlaylist(BufferItem item) { PlaylistBufferItem pbi = item as PlaylistBufferItem; _output.OutputMessage(StringStore.LoadingPlaylist, false); var playlist = SpotifyController.GetPlaylist(pbi.Model.Pointer, true); buffers.Add(new PlaylistBufferList(playlist)); buffers.CurrentListIndex = buffers.Count - 1; var playlistBuffer = buffers.CurrentList; _output.OutputMessage(playlistBuffer.ToString(), false); _output.OutputMessage(String.Format("{0} {1}", playlist.TrackCount, StringStore.TracksLoaded), false); var tracks = playlist.GetTracks(); tracks.ForEach(t => { playlistBuffer.Add(new TrackBufferItem(t)); }); }
public void spotifyConnect() { SpotifyController spotifyController = new SpotifyController(); ContentResult result = spotifyController.GetSpot(); tempVar = HttpContext.Request.GetEncodedUrl().ToString().Split("=")[1]; ContentResult someThing = spotifyController.Get(tempVar); tempVar = someThing.Content.ToString(); if (tempVar != null) { dynamic stuff1 = Newtonsoft.Json.JsonConvert.DeserializeObject(tempVar); string thisText = stuff1.access_token; tempVar = thisText; } _spotify = new SpotifyWebAPI() { AccessToken = tempVar, TokenType = "Bearer" }; }
public VoiceControlEngine(KinectSensor sensor) { this.sensor = sensor; this.ri = GetKinectRecognizer(); this.spotifyController = new SpotifyController(); }
public SpotifyInformation(SpotifyController controller) // our constructor has a controller reference so we can retreive information from the current audio session. { this.controller = controller; }
public BlockTableEditorForm(SpotifyController spotControl) { this.spotControl = spotControl; InitializeComponent(); }
protected override void OnLoad(EventArgs e) { if (settings.UpdatesInterestedIn != UserSettings.UpdateType.None) { updater.CheckForNewVersion(); } if (downloadedUpdate) { this.Close(); return; } SpotifyController.Initialize(); var appKeyBytes = Properties.Resources.spotify_appkey; LoadBufferWindowCommands(); KeyManager = BufferHotkeyManager.LoadFromTextFile(this); string username = "", password = ""; // the first one controls the loop, the second is the response from Libspotify's login call bool isLoggedIn = false, logInResponse = false; while (!isLoggedIn) { using (LoginWindow logon = new LoginWindow()) { var response = logon.ShowDialog(); if (response != DialogResult.OK) { this.Close(); output.OutputMessage(StringStore.ExitingProgram); return; } username = logon.Username; password = logon.Password; } try { output.OutputMessage(StringStore.LoggingIn); logInResponse = SpotifyController.Login(appKeyBytes, username, password); } catch (Exception ex) { MessageBox.Show(StringStore.ErrorDuringLoad + "\\r\\nInitialization: " + ex.Message, StringStore.Oops, MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } if (logInResponse) { output.OutputMessage(StringStore.LoggedInToSpotify); UserSettings.Instance.Username = username; UserSettings.Save(); spotify.SetPrivateSession(UserSettings.Instance.StartInPrivateSession); isLoggedIn = true; } else { var reason = spotify.GetLoginError().Message; MessageBox.Show(reason, StringStore.LogInFailure, MessageBoxButtons.OK, MessageBoxIcon.Error); } } output.OutputMessage(StringStore.LoadingPlaylists, false); var playlists = LoadUserPlaylists(); if (playlists == null) { return; } var playlistsBuffer = Buffers[1] as PlaylistContainerBufferList; if (playlistsBuffer == null) { throw new NullReferenceException("PlaylistsBuffer is null"); } playlistsBuffer.Clear(); playlists.ForEach(p => { playlistsBuffer.Add(new PlaylistBufferItem(p)); }); // we put a reference to the session container on the playlists buffer // so that it can subscribe to playlist added and removed events and in future maybe other things playlistsBuffer.Model = PlaylistContainer.GetSessionContainer(); output.OutputMessage(String.Format("{0} {1}", playlists.Count, StringStore.PlaylistsLoaded), false); Buffers.CurrentListIndex = 1; // start on the playllists list output.OutputBufferListState(Buffers, NavigationDirection.None, false); }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { InitializeComponent(); this.spotifyController = new SpotifyController(); }