@@ -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 );
5857 private StateWrapper state ;
5958 private PlayerSession playerSession ;
6059 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 . clear () ;
210+ metrics = null ;
211211 } else if (playerSession != null ) {
212212 endMetrics (playerSession .currentPlaybackId (), reason , playerSession .currentMetrics (), state .getPosition ());
213213 }
@@ -501,6 +501,14 @@ 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+ }
504512
505513 String contextDesc = state .getContextMetadata ("context_description" );
506514
@@ -532,16 +540,8 @@ private void loadAutoplay() {
532540 state .updated ();
533541 }
534542 } catch (IOException | MercuryClient .MercuryException ex ) {
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- }
543+ LOGGER .fatal ("Failed loading autoplay station!" , ex );
544+ panicState (null );
545545 } catch (AbsSpotifyContext .UnsupportedContextException ex ) {
546546 LOGGER .fatal ("Cannot play local tracks!" , ex );
547547 panicState (null );
0 commit comments