@@ -54,10 +54,10 @@ public class Player implements Closeable, DeviceStateHandler.Listener, PlayerSes
5454 private final PlayerConfiguration conf ;
5555 private final EventsDispatcher events ;
5656 private final AudioSink sink ;
57+ private final Map <String , PlaybackMetrics > metrics = new HashMap <>(5 );
5758 private StateWrapper state ;
5859 private PlayerSession playerSession ;
5960 private ScheduledFuture <?> releaseLineFuture = null ;
60- private Map <String , PlaybackMetrics > metrics = new HashMap <>(5 );
6161
6262 public Player (@ NotNull PlayerConfiguration conf , @ NotNull Session session ) {
6363 this .conf = conf ;
@@ -207,7 +207,7 @@ private void panicState(@Nullable PlaybackMetrics.Reason reason) {
207207 state .updated ();
208208
209209 if (reason == null ) {
210- metrics = null ;
210+ metrics . clear () ;
211211 } else if (playerSession != null ) {
212212 endMetrics (playerSession .currentPlaybackId (), reason , playerSession .currentMetrics (), state .getPosition ());
213213 }
@@ -501,14 +501,6 @@ private void loadAutoplay() {
501501 return ;
502502 }
503503
504- if (context .startsWith ("spotify:search:" )) {
505- LOGGER .info ("Cannot load autoplay for search context: " + context );
506-
507- state .setPosition (0 );
508- state .setState (true , false , false );
509- state .updated ();
510- return ;
511- }
512504
513505 String contextDesc = state .getContextMetadata ("context_description" );
514506
@@ -540,8 +532,16 @@ private void loadAutoplay() {
540532 state .updated ();
541533 }
542534 } catch (IOException | MercuryClient .MercuryException ex ) {
543- LOGGER .fatal ("Failed loading autoplay station!" , ex );
544- panicState (null );
535+ if (ex instanceof MercuryClient .MercuryException && ((MercuryClient .MercuryException ) ex ).code == 400 ) {
536+ LOGGER .info ("Cannot load autoplay for search context: " + context );
537+
538+ state .setPosition (0 );
539+ state .setState (true , true , false );
540+ state .updated ();
541+ } else {
542+ LOGGER .fatal ("Failed loading autoplay station!" , ex );
543+ panicState (null );
544+ }
545545 } catch (AbsSpotifyContext .UnsupportedContextException ex ) {
546546 LOGGER .fatal ("Cannot play local tracks!" , ex );
547547 panicState (null );
0 commit comments