Skip to content

Commit dd273ac

Browse files
committed
For VLC on Windows
1. disabling recording 2. notifying the user 3. when changing player and recording is on, disable VLC from being selected (displaying the "Not Supported" message)
1 parent 52f42aa commit dd273ac

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

pyradio/radio.py

+49-16
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,21 @@ class SelectPlayer(object):
148148
X = Y = maxX = maxY = 0
149149
_win = _parent = None
150150

151-
_players = {
152-
'mpv': ' MPV Media Player',
153-
'mplayer': ' MPlayer Media Player',
154-
'vlc': ' VLC Media Player',
155-
}
156151

157-
def __init__(self, active_player, parent):
152+
def __init__(self, active_player, parent, recording):
153+
self._players = {
154+
'mpv': ' MPV Media Player',
155+
'mplayer': ' MPlayer Media Player',
156+
'vlc': ' VLC Media Player',
157+
}
158158
self._selected = 0
159159
self._active_player = active_player
160+
self._recording = recording
161+
self._no_vlc = False
162+
if recording > 0 and \
163+
platform.startswith('win'):
164+
self._players['vlc'] += ' (Not Supported)'
165+
self._no_vlc = True
160166
self._available_players = [x.PLAYER_NAME for x in player.available_players if x.PLAYER_NAME != self._active_player]
161167
if logger.isEnabledFor(logging.DEBUG):
162168
logger.debug('available players = {}'.format(player.available_players))
@@ -234,8 +240,10 @@ def keypress(self, char):
234240
ord('s'), ord(' '),
235241
ord('l'), curses.KEY_RIGHT
236242
):
237-
return self._available_players[self._selected]
238-
elif char in (ord('h'), ord('q'), curses.KEY_EXIT, 27):
243+
if not self._no_vlc:
244+
return self._available_players[self._selected]
245+
elif char in (ord('h'), curses.KEY_LEFT,
246+
ord('q'), curses.KEY_EXIT, 27):
239247
return None
240248
return ''
241249

@@ -566,6 +574,7 @@ def __init__(self, pyradio_config,
566574
self.ws.GROUP_SELECTION_MODE: self._show_group_selection,
567575
self.ws.GROUP_HELP_MODE: self._show_group_help,
568576
self.ws.RECORD_WINDOW_MODE: self._show_recording_toggle_window,
577+
self.ws.WIN_VLC_NO_RECORD_MODE: self._show_win_no_record,
569578
}
570579

571580
''' list of help functions '''
@@ -6236,15 +6245,34 @@ def _ask_to_save_browser_config_from_browser(self):
62366245
prompt='',
62376246
is_message=True)
62386247

6248+
def _show_win_no_record(self):
6249+
txt = '''
6250+
|VLC| on |Windows| does not support recording.
6251+
6252+
If you really need to record a station, please use one
6253+
of the other two supported players, preferably |MPV|.
6254+
6255+
To use one of them (|MPV| or |MPlayer|), close this window
6256+
and press |\m| to activate it.
6257+
6258+
If none of them is installed, close this window and
6259+
press |F8| to get to the player installation window.
6260+
'''
6261+
self._show_help(txt,
6262+
mode_to_set=self.ws.WIN_VLC_NO_RECORD_MODE,
6263+
caption=' Recording not supported! ',
6264+
prompt='',
6265+
is_message=True)
6266+
62396267
def _show_recording_toggle_window(self):
62406268
if self.player.recording > 0:
62416269
caption = ' Recording Enable '
62426270
txt = ''' _____Next time you play a station,
62436271
_____it will be |written to a file|!
62446272
6245-
A [|r|] at the right top corner of the
6246-
window indicates that recording is |enabled|.
6247-
A [|R|] indicates that a station is actually
6273+
A |[r]| at the right top corner of the window
6274+
indicates that recording is |enabled|.
6275+
A |[R]| indicates that a station is actually
62486276
|being recorded| to a file.
62496277
'''
62506278
else:
@@ -6709,7 +6737,8 @@ def keypress(self, char):
67096737
self.ws.operation_mode = self.ws.CHANGE_PLAYER_MODE
67106738
self._change_player = SelectPlayer(
67116739
active_player=self.player.PLAYER_NAME,
6712-
parent=self.bodyWin
6740+
parent=self.bodyWin,
6741+
recording=self.player.recording
67136742
)
67146743
self._change_player.show()
67156744

@@ -7024,7 +7053,9 @@ def keypress(self, char):
70247053
self._add_station_to_stations_history,
70257054
self._recording_lock
70267055
)
7027-
self.player.recording = to_record
7056+
if not (self.player.PLAYER_NAME == 'vlc' and \
7057+
platform.startswith('win')):
7058+
self.player.recording = to_record
70287059
self.log.display_help_message = False
70297060
self.log.write(ret + ': Player activated!!!', help_msg=False, suffix='')
70307061
self.player.volume = -1
@@ -7033,6 +7064,7 @@ def keypress(self, char):
70337064
self.setStation(to_play)
70347065
self.playSelection()
70357066
self.refreshBody()
7067+
self._change_player = None
70367068

70377069
elif self.ws.operation_mode == self.ws.REMOTE_CONTROL_SERVER_ACTIVE_MODE:
70387070
if char == ord('s'):
@@ -8627,7 +8659,10 @@ def keypress(self, char):
86278659
if char == ord('|'):
86288660
self._reset_status_bar_right()
86298661
# if self.player.PLAYER_NAME != 'vlc':
8630-
if self.player.PLAYER_NAME:
8662+
if self.player.PLAYER_NAME == 'vlc' and \
8663+
platform.startswith('win'):
8664+
self._show_win_no_record()
8665+
else:
86318666
self.player.recording = 1 if self.player.recording == 0 else 0
86328667
if self.player.recording > 0:
86338668
if self.player.isPlaying():
@@ -8638,8 +8673,6 @@ def keypress(self, char):
86388673
self.player.already_playing = False
86398674
self._show_recording_status_in_header()
86408675
self._show_recording_toggle_window()
8641-
else:
8642-
self._print_not_implemented_yet()
86438676

86448677
elif char == curses.ascii.BEL:
86458678
''' ^G - show groups '''

pyradio/window_stack.py

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class Window_Stack_Constants(object):
140140
CHANGE_PLAYER_SAME_PLAYER_ERROR_MODE = 323
141141
EDIT_STATION_ICON_URL_ERROR = 324
142142
EDIT_STATION_ICON_FORMAT_ERROR = 325
143+
WIN_VLC_NO_RECORD_MODE = 326
143144
THEME_MODE = 400
144145
HISTORY_EMPTY_NOTIFICATION = 500
145146
NO_BROWSER_SEARCH_RESULT_NOTIFICATION = 501
@@ -286,6 +287,7 @@ class Window_Stack_Constants(object):
286287
GROUP_SEARCH_MODE: 'GROUP_SEARCH_MODE',
287288
GROUP_HELP_MODE: 'GROUP_HELP_MODE',
288289
RECORD_WINDOW_MODE: 'RECORD_WINDOW_MODE',
290+
WIN_VLC_NO_RECORD_MODE: 'WIN_VLC_NO_RECORD_MODE' ,
289291
}
290292

291293
''' When PASSIVE_WINDOWS target is one of them,
@@ -373,6 +375,7 @@ class Window_Stack_Constants(object):
373375
UPDATE_STATIONS_CSV_RESULT_MODE,
374376
GROUP_HELP_MODE,
375377
RECORD_WINDOW_MODE,
378+
WIN_VLC_NO_RECORD_MODE,
376379
)
377380

378381
def __init__(self):

0 commit comments

Comments
 (0)