Closed timendez closed 4 years ago
Changed the Log Level
to All
and didn't gain any insight.
Same errors even when upgraded to Unity 2019.2.0f1
Hey, thanks for the awesome report. I currently don't have an Android phone on me so I can't test and fix it for a while (cause I'm current away from my main computer).
Does this occur within the Editor or only on Android builds? Also, are you building with scripting backend Mono or IL2CPP? I've had some other problems come up recently from others who are using IL2CPP and didn't realise that was something that could break everything.
I've been using Mono, I get an error when building with IL2CPP
I get a different error when trying to login within the editor:
IndexOutOfRangeException: Index was outside the bounds of the array.
Spotify4Unity.MobileSpotifyService.GetArgs () (at <0bd7703ae3e94409b241057c87cbc69e>:0)
Spotify4Unity.MobileSpotifyService.Connect () (at <0bd7703ae3e94409b241057c87cbc69e>:0)
SpotifyController+<asyncConnect>d__9.MoveNext () (at Assets/Scripts/SpotifyController.cs:53)
It occurs when I try to Connect()
- the SpotifyService
is still not null. I might be doing something wrong still, but I followed the instructions here for setup.
The only reason that can crash is if you're supplying a different url than it's expecting into URL Authentification. It should be similar to "http://localhost:4002/#access_token=abcdefg123456.......". You should put the WHOLE of the url inside that box, not just the part after "access_token=...".
Also check that the authentification worked. If you haven't done step 1 correctly (added another redirect url to your spotify dashboard), the url won't contain an access token, which then causes it to fail
Ah that's it, where do you get the access token? When I press authorize I get the following URL, which I then copied into my URL Authentification
box:
https://accounts.spotify.com/authorize?client_id={redacted}&response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A4002&scope=playlist-modify-public%20playlist-modify-private%20playlist-read-private%20streaming%20user-read-private%20user-read-email%20user-library-read%20user-library-modify%20user-follow-modify%20user-follow-read%20user-read-birthdate%20user-top-read%20playlist-read-collaborative%20user-read-recently-played%20user-read-playback-state%20user-modify-playback-state%20user-read-currently-playing%20
Ok I had read the instructions wrong and created a new app to try and get it working in the editor. I got the correct URL Authentification
URL and am able to connect within the editor. I still receive the following warnings:
Thanks for your help - I'm going to continue trying to make progress from within the editor now, but let me know if you have any more insight
Yep, you figured it out. I also understand why you're getting the EventManager warnings. It's because the SpotifyService is firing those events however there isn't any listeners (Any scripts inheriting from SpotifyUIBase, since it will listen for those). I was thinking of hiding this warning actually since it's not a major problem if there isn't anything listening
For now I suggest doing changing your SpotifyController to this. It hides the warnings and I'll change that warning message to appear less, while still being useful.
using Spotify4Unity;
using Spotify4Unity.Events;
using UnityEngine.UI;
public class SpotifyController : SpotifyUIBase
{
public Button LoginButton;
public SceneController sceneController;
protected override void Awake()
{
base.Awake();
// Prevent the gameobject from being destroyed when the scene changes
DontDestroyOnLoad(gameObject);
}
void Start()
{
//Login(); // Or call it from a button in your scene. I am calling it from a button.
}
public void Login()
{
SpotifyService.Connect();
}
protected override void OnConnectedChanged(ConnectedChanged e)
{
base.OnConnectedChanged(e);
if (e.IsConnected)
{
sceneController.ChangeScene();
}
}
}
Okay thanks! That's helped me narrow down the bug - I think it's a problem with my current Unity version mixed with my Google VR version. I'm going to go ahead and close this out as I really doubt this package is the culprit.
Describe the bug When I try to connect to the SpotifyService on Android, I receive the following:
And the
TrackTimeChanged
event error keeps logging indefinitely. I was able to still accurately get information about the current track I was listening to, so the connection is still solid.However, since this bug has shown up (since I upgraded from v1.4 to v1.4.5), I haven't been able to switch scenes or manually switch to VR mode. In fact, after coming back from the browser, the
Update()
function in my scripts no longer fires, even thoughmyScriptInstance.enabled
returnstrue
.To Reproduce:
Android
as the platform for Mobile Spotify Authorization on the Mobile Spotify Service.public class SpotifyController : MonoBehaviour { public SpotifyServiceBase SpotifyService; public Button LoginButton; public SceneController sceneController;
void Awake() { // Prevent the gameobject from being destroyed when the scene changes DontDestroyOnLoad(gameObject); }
void Start() { Login(); // Or call it from a button in your scene. I am calling it from a button. }
private void Login() { if (SpotifyService != null) { StartCoroutine(asyncConnect()); } else { Debug.LogError("SpotifyService hasn't been set!"); } }
private IEnumerator asyncConnect() { SpotifyService.Connect(); yield return new WaitForSeconds(0.3f); if (SpotifyService.IsConnected) { sceneController.ChangeScene(); } } }
Expected behavior I expect no errors to log from Spotify4Unity, and the ability to change scenes
Platform:
Unity Version:
Spotify4Unity Version: v1.4.5 & v1.4.6
If there's a way to try versions before v1.4.5 I'll try that, too
Edit: Tested on multiple devices, same behavior