Exemplo n.º 1
1
        private void UpdateForm(Spotify.SpotifyStatus status)
        {
            ++_counter;
              if (this.InvokeRequired)
              {
            this.Invoke(new UpdateFormDel(UpdateForm), status);

              }

              lblPlaying.Text = String.Format("Currently Playing: {0} - {1}", status.Artist, status.Track);
              lblPosition.Text = String.Format("{0} / {1}", status.Position, status.Length);

              if (_counter < 4)
              {
            return;
              }

              if (!String.IsNullOrEmpty(_currentId) && !status.TrackID.EndsWith(_currentId))
              {
             Spotify.SpotifyHelpers.StopPlayback();
            _socket.Emit("player:remoteItemStopped", new { stream = txtStreamID.Text.Trim() });
            _currentId = null;
            Console.WriteLine("player:remoteItemStopped");
              }
        }
Exemplo n.º 2
0
        public static ILink FromLink(this ISession session, string link)
        {
            IntPtr linkHandle;

            lock (Spotify.Mutex)
            {
                linkHandle = Spotify.sp_link_create_from_string(link);
            }

            return(LinkManager.Get(session, linkHandle, link));
        }
Exemplo n.º 3
0
 public static ILink <ITrackAndOffset> ToLink(this ITrack track, TimeSpan offset)
 {
     return(CreateLink <ITrackAndOffset>(
                () =>
     {
         var wrapper = track as INativeObject;
         return wrapper == null ? IntPtr.Zero : wrapper.Handle;
     },
                track.Session,
                h => Spotify.sp_link_create_from_track(h, (int)offset.TotalMilliseconds)));
 }
Exemplo n.º 4
0
 public static ILink <ITrackAndOffset> ToLink(this ITrack track)
 {
     return(CreateLink <ITrackAndOffset>(
                () =>
     {
         var wrapper = track as INativeObject;
         return wrapper == null ? IntPtr.Zero : wrapper.Handle;
     },
                track.Session,
                h => Spotify.sp_link_create_from_track(h, 0)));
 }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        thisGameObject = transform.root.gameObject;
        meshRenderers  = thisGameObject.GetComponentsInChildren <MeshRenderer>();

        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();
        saveLoad             = spotifyManager.GetComponent <SaveLoad>();

        //  StartCoroutine(LoadUserPlaylists());
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Spotify.Welcome();

            Spotify.ShowName();

            Spotify.ShowTrack();



            Console.ReadLine();
        }
    public IEnumerator Test_Spotify_GetTrack()
    {
        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();

        string    trackId   = "0Pw6Gg8QChw5iSRRSrcWXP";
        FullTrack fullTrack = spotifyManagerScript.GetTrack(trackId);

        yield return(new WaitForFixedUpdate());

        Assert.IsFalse(fullTrack.HasError());
    }
Exemplo n.º 8
0
 /// <summary>
 /// Assert (and ensure) that nothing is running
 /// </summary>
 static void NothingRunning()
 {
     Zoom.Stop();
     zoomRunning = false;
     DvbViewer.Stop();
     if (spotifyRunning)
     {
         Spotify.Stop();
     }
     runningProgram = "";
     logger.Info("NothingRunning");
 }
Exemplo n.º 9
0
 public void LogOut()
 {
     if (_currentState == SpotifyState.Playing)
     {
         StopMusic();
     }
     if (_currentState == SpotifyState.LoggedIn)
     {
         Spotify.LogOut();
         _currentState = SpotifyState.Initialized;
     }
 }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        spotifyManager = GameObject.Find("SpotifyManager");
        spotifyScript  = spotifyManager.GetComponent <Spotify>();

        meshRenderer = GetComponent <MeshRenderer>();

        text              = GameObject.Find("ArtistName");
        audioAnalysis     = GameObject.Find("AudioAnalysis");
        artistNameText    = text.GetComponent <UnityEngine.UI.Text>();
        audioAnalysisText = audioAnalysis.GetComponent <UnityEngine.UI.Text>();
    }
Exemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     meshRenderer                 = GetComponent <MeshRenderer>();
     spotifyManager               = GameObject.Find("SpotifyManager");
     script                       = spotifyManager.GetComponent <Spotify>();
     recordPlayerScript           = recordPlayer.GetComponent <RecordPlayer>();
     audioVisualizer              = GameObject.Find("AudioVisualizer");
     particleVisualizerGameObject = GameObject.Find("Visualizer Room/ParticleVisualizer");
     particleVisualizer           = particleVisualizerGameObject.GetComponent <ParticleVisualizer>();
     audioVisualizerScript        = audioVisualizer.GetComponent <AudioVisualizer>();
     raycast                      = GameObject.Find("/OVRPlayerController/OVRCameraRig/TrackingSpace/LocalAvatar/controller_right").GetComponent <Raycast>();
 }
Exemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     spotifyManager        = GameObject.Find("SpotifyManager");
     spotifyManagerScript  = spotifyManager.GetComponent <Spotify>();
     saveLoad              = spotifyManager.GetComponent <SaveLoad>();
     recommendationDeck    = GameObject.Find("RecommenderDeck");
     recommenderDeckScript = recommendationDeck.GetComponent <RecommenderDeck>();
     raycast        = RaycastGameObject.GetComponent <Raycast>();
     gameObjectName = transform.name;
     //Ignore collisions between grabble and handUI layer, i.e. hand ui and vinyl (they can collide when holding vinyl)
     Physics.IgnoreLayerCollision(8, 11, true);
 }
Exemplo n.º 13
0
        public IActionResult AddSong(string id, string title, string playlistId)
        {
            var data    = new Db().GetData().FirstOrDefault(s => s.JukeBoxId == playlistId);
            var spotify = new Spotify();

            spotify.AddSong(id, data);
            ViewBag.Message = $"Success, '{title}' added";
            return(View("Search", new SearchModel()
            {
                Songs = new List <Song>(), PlaylistId = playlistId
            }));
        }
Exemplo n.º 14
0
        // GET: /Spotify/GetPlayingInfo
        public ContentResult GetPlayingInfo()
        {
            SpotifyData.Track currentTrack = Spotify.GetCurrentTrack();
            IEnumerable <SpotifyData.Track> queuedTracks = Spotify.GetQueuedTracks();

            if (currentTrack == null)
            {
                XElement stoppedInfo = new XElement("Track",
                                                    new XAttribute("id", ""),
                                                    new XAttribute("name", ""),
                                                    new XAttribute("album", ""),
                                                    new XAttribute("albumid", ""),
                                                    new XAttribute("albumArtist", ""),
                                                    new XAttribute("trackArtists", ""),
                                                    new XAttribute("duration", 0),
                                                    new XAttribute("position", 0),
                                                    new XAttribute("status", "Stopped"),
                                                    new XAttribute("postionDisplay", ""),
                                                    new XAttribute("indexDisplay", ""));

                return(this.Content(stoppedInfo.ToString(), @"text/xml", Encoding.UTF8));
            }

            int pos        = Spotify.GetPosition();
            int trackCount = 0;
            int trackIndex = 0;

            foreach (SpotifyData.Track track in queuedTracks)
            {
                trackCount++;
                if (track.Id == currentTrack.Id)
                {
                    trackIndex = trackCount;
                }
            }

            int playStatus = Spotify.GetPlaying();

            XElement info = new XElement("Track",
                                         new XAttribute("id", currentTrack.Id),
                                         new XAttribute("name", currentTrack.Name),
                                         new XAttribute("album", currentTrack.AlbumName),
                                         new XAttribute("albumid", currentTrack.AlbumId),
                                         new XAttribute("albumArtist", currentTrack.AlbumArtistName),
                                         new XAttribute("trackArtists", currentTrack.TrackArtistNames),
                                         new XAttribute("duration", currentTrack.Duration),
                                         new XAttribute("position", pos),
                                         new XAttribute("status", playStatus == -1 ? "Stolen" : playStatus == 0 ? "Paused" : "Playing"),
                                         new XAttribute("postionDisplay", Spotify.FormatDuration(pos) + "/" + Spotify.FormatDuration(currentTrack.Duration)),
                                         new XAttribute("indexDisplay", trackIndex + "/" + trackCount));

            return(this.Content(info.ToString(), @"text/xml", Encoding.UTF8));
        }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        meshRenderer = GetComponent <MeshRenderer>();
        //    a = meshRenderer.material.color.a;
        //    c = meshRenderer.material.GetColor("_TintColor");

        spotifyManager     = GameObject.Find("SpotifyManager");
        script             = spotifyManager.GetComponent <Spotify>();
        playlistNameText   = playlistNameObject.GetComponent <UnityEngine.UI.Text>();
        spriteRenderer     = spriteGameObject.GetComponent <SpriteRenderer>();
        recordPlayerScript = recordPlayer.GetComponent <RecordPlayer> ();
    }
Exemplo n.º 16
0
        public void Loaded()
        {
            if (!TryLoadSecrets(@"..\..\..\spotify.secret"))
            {
                ShowMessage("Spotify secrets couldnt be loaded");
            }

            spotify = new Spotify(spotifySecrets.ClientID, spotifySecrets.ClientSecret);

            _ = LoadCurrentSong();
            _ = LoadPlaylists();
        }
Exemplo n.º 17
0
        // default to spotify login screen
        public SpotifyEnabledBrowser()
            : base(BaseURL + "login.html")
        {
            Singleton = this;
            Spotify.Initialize();

            Session.OnLoggedIn      += SessionOnOnLoggedIn;
            Session.OnPlayTokenLost += PlayTokenLost;
            HandleCreated           += SpotifyEnabledBrowser_HandleCreated;
            ConsoleMessage          += SpotifyEnabledBrowser_ConsoleMessage;
            Disposed         += SpotifyEnabledBrowser_Disposed;
            IsLoadingChanged += SpotifyEnabledBrowser_IsLoadingChanged;
        }
Exemplo n.º 18
0
        public IActionResult Settings([FromServices] SpotterAzure_dbContext dbContext)
        {
            Spotify sp = authDetails.CheckAuth(Request, dbContext);

            if (sp != null)
            {
                return(View("Settings", sp));
            }
            else
            {
                return(Redirect("LoginError"));
            }
        }
Exemplo n.º 19
0
    // Use this for initialization
    void Start()
    {
        thisGameObject = transform.root.gameObject;
        meshRenderers  = GetComponentsInChildren <MeshRenderer>();

        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();
        saveLoad             = spotifyManager.GetComponent <SaveLoad>();

        //   StartCoroutine(loadNewAlbumReleases());

        //   LoadNewReleasesFromFile();
    }
Exemplo n.º 20
0
    public IEnumerator Test_Spotify_GetUsersFollowedArtists()
    {
        Spotify spotify = new Spotify();

        spotify.TestSetup();

        FollowedArtists followedArtists = spotify.GetUsersFollowedArtists();

        yield return(null);

        Debug.Log(followedArtists.Artists.Items[0].Name);

        Assert.IsFalse(followedArtists.HasError());
    }
Exemplo n.º 21
0
 // GET: /Spotify/PlayPause
 public ContentResult PlayPause()
 {
     if (isPaused)
     {
         Spotify.Play();
         isPaused = false;
     }
     else
     {
         Spotify.Pause();
         isPaused = true;
     }
     return(this.Content(""));
 }
Exemplo n.º 22
0
    public IEnumerator Test_Spotify_GetUsersTopTracks()
    {
        Spotify spotify = new Spotify();

        spotify.TestSetup();

        Paging <FullTrack> usersTopTracks = spotify.GetUsersTopTracks();

        yield return(null);

        Debug.Log(usersTopTracks.Items[0].Name);

        Assert.IsFalse(usersTopTracks.HasError());
    }
    // Use this for initialization
    void Start()
    {
        thisGameObject = transform.root.gameObject;
        meshRenderers  = thisGameObject.GetComponentsInChildren <MeshRenderer>();

        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();

        topTracksScript = topTracksGameObject.GetComponent <TopTracksScript>();

        topArtistsScript = topArtistsGameObject.GetComponent <TopArtistsScript>();

        //   StartCoroutine(LoadUserRecommendations());
    }
Exemplo n.º 24
0
        private async Task UpdateLyrics(Spotify spotify)
        {
            foreach (var provider in _lyricsProviders)
            {
                var lyrics = await provider.ForSong(spotify.CurrentlyPlayingSong);

                if (lyrics != null)
                {
                    lyricsTextBox.Text = lyrics;
                    return;
                }
            }
            lyricsTextBox.Text = "Lyrics not found";
        }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        quads = GetChildGameObjectWithTag("song");

        meshRenderers = GetMeshRenderers(quads);

        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();
        csvReader            = spotifyManager.GetComponent <CSVReader>();
        saveLoad             = spotifyManager.GetComponent <SaveLoad>();
        chartTracks          = csvReader.chartTrackList;

        //     StartCoroutine(LoadChartTracks());
    }
Exemplo n.º 26
0
        public IList <Track> GetRecommendations(List <Artist> artists, List <Track> tracks)
        {
            //Fix for Double.ToString() using ,
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";

            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;


            Dictionary <string, string> seedDictionary = new Dictionary <string, string>();
            TrackFeatures recommendationFeatures       = new TrackFeatures();

            if (tracks.Count > 0)
            {
                recommendationFeatures = AnalyzeTracks(tracks);
                seedDictionary.Add("seed_tracks", string.Join(",", tracks.ConvertAll(t => t.Id)));
            }
            else if (artists.Count > 0)
            {
                var artistsTopTracks = new List <SpotifyTrack>();
                foreach (var artist in artists)
                {
                    var response = Spotify.GetArtistTopTracks(artist.Id);
                    if (response.IsSuccess)
                    {
                        artistsTopTracks.AddRange(response.Content.Tracks);
                    }
                }
                recommendationFeatures = AnalyzeTracks(artistsTopTracks.ConvertAll(SpotifyFactory.CreateTrack));
                seedDictionary.Add("seed_artists", string.Join(",", artists.ConvertAll(t => t.Id)));
            }
            foreach (var feature in recommendationFeatures.GetType().GetProperties())
            {
                seedDictionary.Add($"target_{feature.Name.ToLower()}", feature.GetValue(recommendationFeatures).ToString());
            }
            var recommendationResponse = Spotify.GetSeedRecommendations(seedDictionary);

            if (recommendationResponse.IsSuccess)
            {
                var responseContent = recommendationResponse.Content;
                var returnObject    = new List <Track>();
                foreach (var spotifyTrack in responseContent.Tracks)
                {
                    returnObject.Add(SpotifyFactory.CreateTrack(spotifyTrack));
                }
                return(returnObject);
            }
            return(null);
        }
Exemplo n.º 27
0
        public IActionResult Search(string name, string playlistId)
        {
            var spotify = new Spotify();
            var tracks  = spotify.SearchSongs(name, playlistId);

            if (tracks == null)
            {
                ViewBag.ErrorMessage = "tracks is null";
                return(View("Error"));
            }
            return(View(new SearchModel()
            {
                Songs = tracks, PlaylistId = playlistId
            }));
        }
Exemplo n.º 28
0
 public new void Run()
 {
     Spotify.Initialize();
     if (!Spotify.Login("SOVND_server", _spot.Username, _spot.Password))
     {
         throw new Exception("Spotify login failure");
     }
     LogTo.Trace("Logged into Spotify");
     while (!Spotify.Ready())
     {
         Thread.Sleep(100);
     }
     Connect();
     LogTo.Debug("Connected to MQTT");
 }
Exemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        spotifyManager       = GameObject.Find("SpotifyManager");
        spotifyManagerScript = spotifyManager.GetComponent <Spotify>();

        for (int i = 0; i < cubeLoudness.transform.childCount; i++)
        {
            cubeChildren.Add(cubeLoudness.transform.GetChild(i).gameObject);
        }

        //getting initial reference scales
        x = cubeChildren[0].transform.localScale.x;
        y = cubeChildren[0].transform.localScale.y;
        z = cubeChildren[0].transform.localScale.z;
    }
Exemplo n.º 30
0
        private void InitActionMapping()
        {
            _actionMapping = new Dictionary <JukeboxCommand, Action>();
            foreach (var item in Enum.GetNames(typeof(JukeboxCommand)))
            {
                _actionMapping.Add((JukeboxCommand)Enum.Parse(typeof(JukeboxCommand), item), () => { });
            }

            _actionMapping[JukeboxCommand.NextTrack]       = () => Spotify.SendAction(SpotifyAction.NextTrack);
            _actionMapping[JukeboxCommand.PreviousTrack]   = () => Spotify.SendAction(SpotifyAction.PreviousTrack);
            _actionMapping[JukeboxCommand.Play]            = PlayIfPaused;
            _actionMapping[JukeboxCommand.PlayAfterPaused] = PlayIfPaused;
            _actionMapping[JukeboxCommand.Pause]           = PauseIfPlaying;
            _actionMapping[JukeboxCommand.Toggle]          = () => Spotify.SendAction(SpotifyAction.PlayPause);
        }
Exemplo n.º 31
0
        public bool TryStartPlaylist(String playlistName, bool randomize)
        {
            _numberOfIterations = 0;
            if (_currentState == SpotifyState.Initialized)
            {
                LogIn();
            }
            bool returnVal = Spotify.TryStartPlaylist(playlistName, randomize);

            if (returnVal)
            {
                _currentState = SpotifyState.Playing;
            }
            return(returnVal);
        }
Exemplo n.º 32
0
        internal HttpStreamingServer(Spotify spotify, SpotifyLinkLookup spotifyLinkLookup)
        {
            #if DEBUG
            if (Log.IsDebugEnabled)
                Log.Debug("HttpStreamingServer");
            #endif

            _spotify = spotify;
            _spotifyLinkLookup = spotifyLinkLookup;

            // Build the base URL.
            StringBuilder urlBuild = new StringBuilder();
            urlBuild.Append(Protocol);
            urlBuild.Append(Host);
            urlBuild.Append(':').Append(Port);
            urlBuild.Append(BasePath);
            BaseUrl = urlBuild.ToString();

            // TCP listener for the HTTP server.
            _listener = new TcpListener(IPAddress.Any, Port);
        }
Exemplo n.º 33
0
        static void RunProgram()
        {
            #if DEBUG
            if (Log.IsInfoEnabled) Log.Info("Started.");
            #endif

            // Get the configuration from the Playdar etc folder.
            string etc = Environment.GetEnvironmentVariable("PLAYDAR_ETC");
            #if DEBUG
            if (Log.IsDebugEnabled)
                Log.Debug("PLAYDAR_ETC=\"" + etc + "\"");
            #endif
            if (string.IsNullOrEmpty(etc))
                etc = "etc";

            string configFilename = etc + "/spotify.conf";

            if (!File.Exists(configFilename))
            {
            #if DEBUG
                if (Log.IsErrorEnabled)
                    Log.Error("Spotify configuration file not found!");
            #endif
                return;
            }

            SimplePropertiesFile config = new SimplePropertiesFile(configFilename);
            string username;
            string password;
            try
            {
                username = config.Sections["spotify"]["username"];
                password = config.Sections["spotify"]["password"];
            }
            catch (Exception)
            {
            #if DEBUG
                if (Log.IsErrorEnabled)
                    Log.Error("Couldn't get username or password from config file!");
            #endif
                return;
            }

            // Login to Spotify.
            Spotify spotify = new Spotify();
            bool loginOk = spotify.Login(username, password);
            if (loginOk)
            {

                // Create a lookup table for Spotify links and UUIDs.
                SpotifyLinkLookup spotifyLinkLookup = new SpotifyLinkLookup();

                // Create an HTTP server for streaming mp3.
                HttpStreamingServer streamServer = new HttpStreamingServer(spotify, spotifyLinkLookup);
                streamServer.Start();

                // Return resolver info.
                SendJsonOutput(SpotifyResolverInfo);

                // Read JSON queries.
                Stream input = Console.OpenStandardInput();
                do
                {
                    string json = JsonMsgUtil.ExtractJsonInput(input);
                    if (String.IsNullOrEmpty(json) || json == "{}")
                    {
            #if DEBUG
                        if (Log.IsInfoEnabled)
                            Log.Info("Empty message received. Leaving message receive loop.");
            #endif
                        break;
                    }

            #if DEBUG
                    if (Log.IsDebugEnabled)
                        Log.Debug(json);
            #endif

                    JObject o = JObject.Parse(json);
                    string msgtype = (string)o["_msgtype"];
                    if (String.IsNullOrEmpty(msgtype))
                    {
            #if DEBUG
                        if (Log.IsWarnEnabled)
                            Log.Warn("No message type provided. Leaving receive loop.");
            #endif
                        break;
                    }
                    else if (msgtype != "rq")
                    {
            #if DEBUG
                        if (Log.IsWarnEnabled)
                            Log.Warn("Unexpected JSON _msgtype! " + msgtype);
            #endif
                        break;
                    }

            #if DEBUG
                    if (Log.IsDebugEnabled)
                        Log.Debug("Performing search...");
            #endif

                    // Perform search.
                    string artist = (string)o["artist"];
                    string track = (string)o["track"];
                    string album = (string)o["album"];
                    List<Track> searchResults = spotify.Search(artist, track, album);

            #if DEBUG
                    if (Log.IsDebugEnabled)
                        Log.Debug("searchResults.Count = " + searchResults.Count);
            #endif

                    // Build JSON results.
                    StringBuilder jsonBuild = new StringBuilder();
                    JsonTextWriter jsonWriter = new JsonTextWriter(new StringWriter(jsonBuild));
                    jsonWriter.WriteStartObject();
                    WriteProperty(jsonWriter, "_msgtype", "results");
                    WriteProperty(jsonWriter, "qid", (string)o["qid"]);
                    jsonWriter.WritePropertyName("results");
                    jsonWriter.WriteStartArray();
                    int i = 0;
                    foreach (Track r in searchResults)
                    {
                        // Limit number of possible results.
                        if (++i > MaxResults)
                        {
            #if DEBUG
                            if (Log.IsWarnEnabled)
                                Log.Warn("Only returning first " + MaxResults +
                                    " of " + searchResults.Count + " results.");
            #endif

                            break;
                        }

                        // Obtain a GUID for the stream request.
                        string sid = spotifyLinkLookup.NewGuid(r.LinkString);

                        // Build a URL for the track to be delivered.
                        StringBuilder urlBuild = new StringBuilder();
                        urlBuild.Append(streamServer.BaseUrl).Append(sid);
                        string url = urlBuild.ToString();
            #if DEBUG
                        if (Log.IsDebugEnabled)
                            Log.Debug("Stream URL = " + url);
            #endif

                        // Work out the content length.
            #if DEBUG
                        if (Log.IsDebugEnabled) Log.Debug("Duration: " + r.Duration);
            #endif
                        int seconds = r.Duration / 1000;

                        // Add track result to JSON response.
                        jsonWriter.WriteStartObject();
                        WriteProperty(jsonWriter, "artist", r.Artists[0].Name);
                        WriteProperty(jsonWriter, "track", r.Name);
                        WriteProperty(jsonWriter, "album", r.Album.Name);
                        WriteProperty(jsonWriter, "mimetype", "audio/mpeg");
                        WriteProperty(jsonWriter, "source", "Spotify");
                        WriteProperty(jsonWriter, "url", url);
                        WriteProperty(jsonWriter, "duration", seconds);
                        WriteProperty(jsonWriter, "score", CalculateScore(r, artist, track, album));
                        WriteProperty(jsonWriter, "bitrate", LameProgram.BitRate);
                        jsonWriter.WriteEndObject();
                    }
                    jsonWriter.WriteEnd();
                    jsonWriter.WriteEndObject();

                    // Send the JSON response to search query.
                    SendJsonOutput(jsonBuild.ToString());

                } while (true);

                // Tidy up after stream server.
                streamServer.Shutdown();

                // Logout of Spotify.
                spotify.Logout();

            }
        }