@@ -98,35 +98,35 @@ def set_status(label, action_text, player):
9898 group .append (border )
9999
100100 while radio .connected :
101- try :
102- for connection in radio . connections :
101+ for connection in radio . connections :
102+ try :
103103 if not connection .paired :
104104 connection .pair ()
105105 print ("paired" )
106106
107107 ams = connection [AppleMediaService ]
108- set_label ( title_label , ams . title , 18 )
109- set_label ( album_label , ams . album , 21 )
110- set_label ( artist_label , ams . artist , 21 )
111- action = "?"
112- if ams .playing :
113- action = "Playing"
114- elif ams . paused :
115- action = "Paused"
116- set_status ( status_label , action , ams . player_name )
117- if cp . button_a :
118- ams . toggle_play_pause ()
119- time . sleep ( 0.1 )
120-
121- if cp . button_b :
122- if cp . switch :
123- ams . previous_track ()
124- else :
125- ams . next_track ()
126- time . sleep ( 0.1 )
127- except ( RuntimeError , UnsupportedCommand ) :
128- # Skip Bad Packets, unknown commands, etc.
129- pass
108+ except ( RuntimeError , UnsupportedCommand , AttributeError ):
109+ # Skip Bad Packets, unknown commands, etc.
110+ continue
111+ set_label ( title_label , ams . title , 18 )
112+ set_label ( album_label , ams .album , 21 )
113+ set_label ( artist_label , ams . artist , 21 )
114+ action = "?"
115+ if ams . playing :
116+ action = "Playing"
117+ elif ams . paused :
118+ action = "Paused"
119+ set_status ( status_label , action , ams . player_name )
120+ if cp . button_a :
121+ ams . toggle_play_pause ()
122+ time . sleep ( 0.1 )
123+
124+ if cp . button_b :
125+ if cp . switch :
126+ ams . previous_track ( )
127+ else :
128+ ams . next_track ()
129+ time . sleep ( 0.1 )
130130
131131 print ("disconnected" )
132132 # Remove all layers
0 commit comments