-
-
Notifications
You must be signed in to change notification settings - Fork 99
Description
Is your feature request related to a problem? Please describe.
Sometimes the librespot 'Player' will fail to load a spotify track, for multiple reasons.
One of them can be 'content is restricted' :
2022-01-08 19:56:15.343 20022-20105/v.blade E/x.g.l.p.Player: Can't load track (content restricted).
xyz.gianlu.librespot.audio.PlayableContentFeeder$ContentRestrictedException
at xyz.gianlu.librespot.audio.PlayableContentFeeder.loadTrack(PlayableContentFeeder.java:110)
at xyz.gianlu.librespot.audio.PlayableContentFeeder.load(PlayableContentFeeder.java:86)
at xyz.gianlu.librespot.player.playback.PlayerQueueEntry.load(PlayerQueueEntry.java:115)
at xyz.gianlu.librespot.player.playback.PlayerQueueEntry.run(PlayerQueueEntry.java:276)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
To my understanding, there is no way to act in that case, to notify the user : the Player.EventsListener does not include a playback failed event. All i receive is a 'track changed' event, telling me that the player skipped to next track.
I could use some tricks like looking at the player current time() on track changed, and if zero notify the user that there was a problem, but i can't get a description of the problem anyway.
Describe the solution you'd like
An event in the EventsListener that would be 'load failed' or 'playback failed' and give a string/int describing the reason why the playback/load failed.
Describe alternatives you've considered
Maybe the load function could return an int describing if the load went well ? I think that is harder to implement (load() must do some async work, right ?) and maybe less elegant then.
An other way would be a getLastError() method that we could call on the track changed event.
Any way to access player error would be good.
Additional context
I'm sorry if there is already a way to see if the player failed, but i could not find it...