public void GetRequestCompleted(VentanaInteractable ventana) { SonosInfo info = ventana as SonosInfo; isMusicPlaying = !info.isPaused; BroadcastMessage("OnURLSent", ventana); }
void OnURLSent(VentanaInteractable venta) { //album art contains the URL SonosInfo info = venta as SonosInfo; //Debug.Log(info.album_art); if (newURL != info.album_art) { Debug.Log("Im getting changed"); WWW www = new WWW(info.album_art); newURL = info.album_art; songText.text = info.title; albumText.text = info.artist; StartCoroutine(ChangeAlbumTexture(www)); } }
public void HandlePush(SocketIOEvent e) { Debug.Log("[SocketIO]" + e.data); VentanaInteractable myVentana = SonosInfo.CreateFromJSON(e.data.GetField(vmc.VentanaID.ToString()).ToString()); if (myVentana as SonosInfo != null) { SonosInfo ventana = (SonosInfo)myVentana; if (ventana.isPaused) { gameObject.SendMessageUpwards("SetPauseState"); } else { gameObject.SendMessageUpwards("SetPlayState"); } OnURLSent(myVentana); } }
public IEnumerator GetFromMusicAPIEndpoint(string action, int id, Action <VentanaInteractable> callback) { StringBuilder url = new StringBuilder(HoloHubURI); url.Append(MusicEndpoint); url.Append(action + "/"); //url.Append(id.ToString()); //realistically its only for status... url.Append(id.ToString()); url.Append("/"); Debug.Log("ACTION: " + action + " URL: " + url.ToString()); UnityWebRequest holoHubRequest = UnityWebRequest.Get(url.ToString()); yield return(holoHubRequest.Send()); if (!holoHubRequest.isError) { //Debug.Log("WWW Ok!: " + responseString); if (action == "status" && callback != null) { try { VentanaInteractable myVentana = SonosInfo.CreateFromJSON(holoHubRequest.downloadHandler.text); if (myVentana != null) { callback(myVentana); } } catch (ArgumentException e) { Debug.LogWarning(e.Message + " \nHoloHub Response Val: " + holoHubRequest.downloadHandler.text); } } } else { Debug.Log("WWW Error: " + holoHubRequest.error); } }