pvrs12 / Anesidora

Anesidora - Pandora extension for Firefox
Other
31 stars 8 forks source link

Songs not loading and skipping one after the other #87

Closed wzdew closed 2 years ago

wzdew commented 2 years ago

Sometimes after using the Firefox plug-in, if I'm out and about on my phone using the official app, songs will just skip one after the other with no play back. If I let it go for a while, it does seem to fix itself. I've noticed though that if I switch from my WiFi to mobile data, the issue immediately goes away on my phone. This wasn't too big of a deal until it started happening on the Firefox plug-in as well. Last time I was able to fix it by uninstalling the plug-in completely and then reinstalling it, but subsequent attempts haven't worked. I've tried using a different account for the plug-in and that seems to work just fine. I've also gone to the site directly and that seems to work there with other accounts, but not the affected account. I've tried logging out and back in to the affected account, but that doesn't solve the issue. It gets the song title and album art, but fails to start the song and eventually skips and repeats this process indefinitely.

I'm not sure exactly what is causing the problem. Any ideas on what's happening and/or a way to avoid/solve this problem without too much trouble?

hucario commented 2 years ago

I don't know why they would be, but it sounds like your songs are expiring.

So, basically how it works is this:

  1. You play a station on pandora (station.getPlaylist)
  2. Pandora gives you access to a bunch of mp3s for a while, I don't know how long precisely but I'd say about 10 minutes per song
  3. After the song expires you lose access to the song.
  4. When the player notices "hey wait I'm trying to play this but it's erroring" its error handling says to skip the song, so it does
  5. The player skips through all the songs, as they expire at around the same time
  6. Once the current playlist is over (you get songs in batches of ~4) the player gets a playlist again (station.getPlaylist)
  7. Pandora enables some songs and sends the links to the player
  8. Player... plays them

So, why would these be expiring? The main reason why these expire is when you pause for a while. The song expiry does not pause while your music is paused, so if you're paused for too long you lose access. Other than that, I don't know.

We could mitigate this by preloading all the songs in the playlist when we get the playlist. That way, we have the song data even if we lose access. However, this means that

  1. If you skip a song early through, we've still downloaded the track - wasted bandwidth
  2. If you switch to a different station, we've still downloaded the tracks, even if they haven't played - wasted bandwidth
  3. The initial loading will take a while, because you'll be downloading four(-ish) tracks instead of just the bit you're listening to[0]

Not much of an issue on wifi (and admittedly this is a browser extension so mobile isn't used nearly as much) but it's still an issue.

[0] - this could be mitigated by preloading the other songs once the current song is finished loading
wzdew commented 2 years ago

I do pause the player a lot. I was thinking something along the same lines earlier, so I limited the number of songs downloaded to 1 in the options for the plug-in, but that hasn't had any apparent effect.

The default client hasn't backed up like this for me before using Anesidora; how does Pandora handle this problem itself? I've been able to pause tracks on their default client and if it goes too long, it just loads a new song when I unpause it.

hucario commented 2 years ago

I do pause the player a lot. I was thinking something along the same lines earlier, so I limited the number of songs downloaded to 1 in the options for the plug-in, but that hasn't had any apparent effect.

The default client hasn't backed up like this for me before using Anesidora; how does Pandora handle this problem itself? I've been able to pause tracks on their default client and if it goes too long, it just loads a new song when I unpause it.

As far as I remember Pandora does the same thing we do, they just don't update the UI while they're doing it and they do it in a slightly more direct way. We try every song once they expire (error -> skip -> next song errors -> skip -> ... -> playlist is empty -> get new songs -> play) Pandora (again, as far as I remember) just directly gets rid of the rest of the playlist once any of them errors, which feels faster because ordinarily you can't see the playlist anyways. (error -> remove all songs from playlist -> get new songs -> play)

pvrs12 commented 2 years ago

I don't think there is anything to actually fix here. If anyone disagrees feel free to leave a comment/re-open

hucario commented 2 years ago

We have two actions here that we could implement:

  1. audio.onError could skip entire playlist instead of just the current song, as it's likely that the entire playlist is expired if the song is
  2. preload all audio files I'm probably not doing either right now, but thought it would be good to list them