예제 #1
0
 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
        }
예제 #3
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     SpotifyController.ShutDown();
     playbackManager.Dispose();
     _trayIcon.Visible = false; // remove tray icon
     base.OnFormClosing(e);
 }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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;
        }
예제 #7
0
        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)));
            });
        }
예제 #8
0
        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)));
            });
        }
예제 #9
0
        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));
            });
        }
예제 #10
0
        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();
 }
예제 #12
0
 public SpotifyInformation(SpotifyController controller) // our constructor has a controller reference so we can retreive information from the current audio session.
 {
     this.controller = controller;
 }
예제 #13
0
 public BlockTableEditorForm(SpotifyController spotControl)
 {
     this.spotControl = spotControl;
     InitializeComponent();
 }
예제 #14
0
        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);
        }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the MainWindow class.
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     this.spotifyController = new SpotifyController();
 }