@@ -230,7 +230,7 @@ class Player(object):
230230 icy_tokens = ()
231231 icy_audio_tokens = {}
232232
233- playback_is_on = False
233+ playback_is_on = connecting = False
234234
235235 _station_encoding = 'utf-8'
236236
@@ -255,9 +255,11 @@ def __init__(self,
255255 outputStream ,
256256 playback_timeout_counter ,
257257 playback_timeout_handler ,
258- info_display_handler ):
258+ info_display_handler ,
259+ history_add_function ):
259260 self .outputStream = outputStream
260261 self ._cnf = config
262+ self .stations_history_add_function = history_add_function
261263 self .config_encoding = self ._cnf .default_encoding
262264 self .config_dir = self ._cnf .stations_dir
263265 try :
@@ -632,7 +634,9 @@ def updateStatus(self, *args):
632634 new_input = self .oldUserInput ['Title' ]
633635 self .outputStream .write (msg = new_input , counter = '' )
634636 self .playback_is_on = True
637+ self .connecting = False
635638 self ._stop_delay_thread ()
639+ self .stations_history_add_function ()
636640 if 'AO: [' in subsystemOut :
637641 with self .status_update_lock :
638642 if version_info > (3 , 0 ):
@@ -665,6 +669,8 @@ def updateStatus(self, *args):
665669 if logger .isEnabledFor (logging .INFO ):
666670 logger .info ('*** updateStatus(): Start of playback detected (Icy-Title received) ***' )
667671 self .playback_is_on = True
672+ self .connecting = False
673+ self .stations_history_add_function ()
668674 ''' detect empty Icy-Title '''
669675 title_without_prefix = title [len (self .icy_title_prefix ):].strip ()
670676 # logger.error('DE title_without_prefix = "{}"'.format(title_without_prefix))
@@ -707,6 +713,8 @@ def updateStatus(self, *args):
707713 if logger .isEnabledFor (logging .INFO ):
708714 logger .info ('*** updateStatus(): Start of playback detected (Icy audio token received) ***' )
709715 self .playback_is_on = True
716+ self .connecting = False
717+ self .stations_history_add_function ()
710718 if enable_crash_detection_function :
711719 enable_crash_detection_function ()
712720 # logger.error('DE token = "{}"'.format(a_token))
@@ -968,7 +976,9 @@ def do_crash_detection(detect_if_player_exited, stop):
968976 new_input = self .oldUserInput ['Title' ]
969977 self .outputStream .write (msg = new_input , counter = '' )
970978 self .playback_is_on = True
979+ self .connecting = False
971980 self ._stop_delay_thread ()
981+ self .stations_history_add_function ()
972982 if 'AO: [' in subsystemOut :
973983 with self .status_update_lock :
974984 if version_info > (3 , 0 ):
@@ -989,7 +999,9 @@ def do_crash_detection(detect_if_player_exited, stop):
989999 except :
9901000 pass
9911001 self .playback_is_on = True
1002+ self .connecting = False
9921003 self ._stop_delay_thread ()
1004+ self .stations_history_add_function ()
9931005 if enable_crash_detection_function :
9941006 enable_crash_detection_function ()
9951007
@@ -1033,7 +1045,9 @@ def do_crash_detection(detect_if_player_exited, stop):
10331045 except :
10341046 pass
10351047 self .playback_is_on = True
1048+ self .connecting = False
10361049 self ._stop_delay_thread ()
1050+ self .stations_history_add_function ()
10371051 if enable_crash_detection_function :
10381052 enable_crash_detection_function ()
10391053 # logger.error('DE token = "{}"'.format(a_token))
@@ -1233,12 +1247,14 @@ def _set_mpv_playback_is_on(self, stop, enable_crash_detection_function):
12331247 self .detect_if_player_exited = True
12341248 if (not self .playback_is_on ) and (logger .isEnabledFor (logging .INFO )):
12351249 logger .info ('*** _set_mpv_playback_is_on(): Start of playback detected ***' )
1250+ self .stations_history_add_function ()
12361251 new_input = 'Playing: ' + self .name
12371252 self .outputStream .write (msg = new_input , counter = '' )
12381253 if self .oldUserInput ['Title' ] == '' :
12391254 self .oldUserInput ['Input' ] = new_input
12401255 self .oldUserInput ['Title' ] = new_input
12411256 self .playback_is_on = True
1257+ self .connecting = False
12421258 if stop ():
12431259 return False
12441260 enable_crash_detection_function ()
@@ -1381,6 +1397,10 @@ def play(self,
13811397 # start playback check timer thread
13821398 self .stop_timeout_counter_thread = False
13831399 if self .playback_timeout > 0 :
1400+ ''' set connecting here insead of Player.play()
1401+ so that we do not use it when timeout = 0
1402+ '''
1403+ self .connecting = True
13841404 try :
13851405 self .connection_timeout_thread = threading .Thread (
13861406 target = self .playback_timeout_counter ,
@@ -1392,10 +1412,12 @@ def play(self,
13921412 if (logger .isEnabledFor (logging .DEBUG )):
13931413 logger .debug ('playback detection thread started' )
13941414 except :
1415+ self .connecting = False
13951416 self .connection_timeout_thread = None
13961417 if (logger .isEnabledFor (logging .ERROR )):
13971418 logger .error ('playback detection thread failed to start' )
13981419 else :
1420+ self .connecting = False
13991421 if logger .isEnabledFor (logging .DEBUG ):
14001422 logger .debug ('playback detection thread not starting (timeout is 0)' )
14011423 if logger .isEnabledFor (logging .INFO ):
@@ -1614,14 +1636,16 @@ def __init__(self,
16141636 outputStream ,
16151637 playback_timeout_counter ,
16161638 playback_timeout_handler ,
1617- info_display_handler ):
1639+ info_display_handler ,
1640+ history_add_function ):
16181641 config .PLAYER_NAME = 'mpv'
16191642 super (MpvPlayer , self ).__init__ (
16201643 config ,
16211644 outputStream ,
16221645 playback_timeout_counter ,
16231646 playback_timeout_handler ,
1624- info_display_handler
1647+ info_display_handler ,
1648+ history_add_function
16251649 )
16261650 self .config_files = self .all_config_files ['mpv' ]
16271651
@@ -2039,14 +2063,16 @@ def __init__(self,
20392063 outputStream ,
20402064 playback_timeout_counter ,
20412065 playback_timeout_handler ,
2042- info_display_handler ):
2066+ info_display_handler ,
2067+ history_add_function ):
20432068 config .PLAYER_NAME = 'mplayer'
20442069 super (MpPlayer , self ).__init__ (
20452070 config ,
20462071 outputStream ,
20472072 playback_timeout_counter ,
20482073 playback_timeout_handler ,
2049- info_display_handler
2074+ info_display_handler ,
2075+ history_add_function
20502076 )
20512077 self .config_files = self .all_config_files ['mplayer' ]
20522078
@@ -2247,14 +2273,16 @@ def __init__(self,
22472273 outputStream ,
22482274 playback_timeout_counter ,
22492275 playback_timeout_handler ,
2250- info_display_handler ):
2276+ info_display_handler ,
2277+ history_add_function ):
22512278 config .PLAYER_NAME = 'vlc'
22522279 super (VlcPlayer , self ).__init__ (
22532280 config ,
22542281 outputStream ,
22552282 playback_timeout_counter ,
22562283 playback_timeout_handler ,
2257- info_display_handler
2284+ info_display_handler ,
2285+ history_add_function
22582286 )
22592287 # self.config_files = self.all_config_files['vlc']
22602288
0 commit comments