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"); } }
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)); }
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))); }
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))); }
// 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()); }
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()); }
/// <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"); }
public void LogOut() { if (_currentState == SpotifyState.Playing) { StopMusic(); } if (_currentState == SpotifyState.LoggedIn) { Spotify.LogOut(); _currentState = SpotifyState.Initialized; } }
// 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>(); }
// 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>(); }
// 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); }
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 })); }
// 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)); }
// 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> (); }
public void Loaded() { if (!TryLoadSecrets(@"..\..\..\spotify.secret")) { ShowMessage("Spotify secrets couldnt be loaded"); } spotify = new Spotify(spotifySecrets.ClientID, spotifySecrets.ClientSecret); _ = LoadCurrentSong(); _ = LoadPlaylists(); }
// 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; }
public IActionResult Settings([FromServices] SpotterAzure_dbContext dbContext) { Spotify sp = authDetails.CheckAuth(Request, dbContext); if (sp != null) { return(View("Settings", sp)); } else { return(Redirect("LoginError")); } }
// 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(); }
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()); }
// GET: /Spotify/PlayPause public ContentResult PlayPause() { if (isPaused) { Spotify.Play(); isPaused = false; } else { Spotify.Pause(); isPaused = true; } return(this.Content("")); }
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()); }
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"; }
// 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()); }
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); }
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 })); }
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"); }
// 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; }
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); }
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); }
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); }
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(); } }