forked from openlp/openlp
revert changes
This commit is contained in:
parent
334eb6c8c5
commit
72a180716b
@ -134,7 +134,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
"""
|
||||
saved_players = get_media_players()[0]
|
||||
for player in list(self.media_players.keys()):
|
||||
self.media_players[player][0].is_active = player in saved_players
|
||||
self.media_players[player].is_active = player in saved_players
|
||||
|
||||
def _generate_extensions_lists(self):
|
||||
"""
|
||||
@ -143,30 +143,28 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
suffix_list = []
|
||||
self.audio_extensions_list = []
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
for item in player[0].audio_extensions_list:
|
||||
if player.is_active:
|
||||
for item in player.audio_extensions_list:
|
||||
if item not in self.audio_extensions_list:
|
||||
self.audio_extensions_list.append(item)
|
||||
suffix_list.append(item[2:])
|
||||
self.video_extensions_list = []
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
for item in player[0].video_extensions_list:
|
||||
if player.is_active:
|
||||
for item in player.video_extensions_list:
|
||||
if item not in self.video_extensions_list:
|
||||
self.video_extensions_list.append(item)
|
||||
suffix_list.append(item[2:])
|
||||
self.service_manager.supported_suffixes(suffix_list)
|
||||
|
||||
def register_players(self, live_player, preview_player):
|
||||
def register_players(self, player):
|
||||
"""
|
||||
Register each media Player (Webkit, Phonon, etc) and store
|
||||
for later use
|
||||
|
||||
:param live_player: Individual player class which has been enabled for live use
|
||||
:param preview_player: Individual player class which has been enabled for preview use
|
||||
:param player: Individual player class which has been enabled
|
||||
"""
|
||||
self.media_players[live_player.name] = {DisplayControllerType.Preview: preview_player,
|
||||
DisplayControllerType.Live: live_player}
|
||||
self.media_players[player.name] = player
|
||||
|
||||
def bootstrap_initialise(self):
|
||||
"""
|
||||
@ -188,14 +186,14 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
log.warning('Failed to import %s on path %s', module_name, path)
|
||||
player_classes = MediaPlayer.__subclasses__()
|
||||
for player_class in player_classes:
|
||||
# player = player_class(self)
|
||||
self.register_players(player_class(self), player_class(self))
|
||||
player = player_class(self)
|
||||
self.register_players(player)
|
||||
if not self.media_players:
|
||||
return False
|
||||
saved_players, overridden_player = get_media_players()
|
||||
invalid_media_players = \
|
||||
[media_player for media_player in saved_players if media_player not in self.media_players or
|
||||
not self.media_players[media_player][0].check_available()]
|
||||
not self.media_players[media_player].check_available()]
|
||||
if invalid_media_players:
|
||||
for invalidPlayer in invalid_media_players:
|
||||
saved_players.remove(invalidPlayer)
|
||||
@ -234,6 +232,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
self.current_media_players[source].update_ui(display)
|
||||
if self.current_media_players[source].state == MediaState.Playing:
|
||||
any_active = True
|
||||
print(source)
|
||||
self.tick(self.display_controllers[source])
|
||||
# There are still any active players - no need to stop live_timer.
|
||||
if any_active:
|
||||
@ -253,8 +252,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
"""
|
||||
css = ''
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
css += player[0].get_media_display_css()
|
||||
if player.is_active:
|
||||
css += player.get_media_display_css()
|
||||
return css
|
||||
|
||||
def get_media_display_javascript(self):
|
||||
@ -263,8 +262,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
"""
|
||||
js = ''
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
js += player[0].get_media_display_javascript()
|
||||
if player.is_active:
|
||||
js += player.get_media_display_javascript()
|
||||
return js
|
||||
|
||||
def get_media_display_html(self):
|
||||
@ -273,8 +272,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
"""
|
||||
html = ''
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
html += player[0].get_media_display_html()
|
||||
if player.is_active:
|
||||
html += player.get_media_display_html()
|
||||
return html
|
||||
|
||||
def register_controller(self, controller):
|
||||
@ -362,8 +361,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
if preview:
|
||||
display.has_audio = False
|
||||
for player in list(self.media_players.values()):
|
||||
if player[0].is_active:
|
||||
player[0].setup(display)
|
||||
if player.is_active:
|
||||
player.setup(display)
|
||||
|
||||
def set_controls_visible(self, controller, value):
|
||||
"""
|
||||
@ -483,7 +482,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
suffix = '*.%s' % media_info.file_info.suffix().lower()
|
||||
used_players = get_media_players()[0]
|
||||
player = self.media_players[used_players[0]]
|
||||
if suffix not in player[0].video_extensions_list and suffix not in player[0].audio_extensions_list:
|
||||
if suffix not in player.video_extensions_list and suffix not in player.audio_extensions_list:
|
||||
# Media could not be loaded correctly
|
||||
critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported Media File'),
|
||||
translate('MediaPlugin.MediaItem', 'File %s not supported using player %s') %
|
||||
@ -590,31 +589,31 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
||||
if title == 'system':
|
||||
if not controller.media_info.is_background or controller.media_info.is_background and \
|
||||
player.can_background:
|
||||
self.resize(display, player[controller.controller_type])
|
||||
self.resize(display, player)
|
||||
if player.load(display):
|
||||
self.current_media_players[controller.controller_type] = player
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
if suffix in player[controller.controller_type].video_extensions_list:
|
||||
if suffix in player.video_extensions_list:
|
||||
if not controller.media_info.is_background or controller.media_info.is_background and \
|
||||
player[controller.controller_type].can_background:
|
||||
self.resize(display, player[controller.controller_type])
|
||||
if player[controller.controller_type].load(display):
|
||||
self.current_media_players[controller.controller_type] = player[controller.controller_type]
|
||||
player.can_background:
|
||||
self.resize(display, player)
|
||||
if player.load(display):
|
||||
self.current_media_players[controller.controller_type] = player
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
if suffix in player[controller.controller_type].audio_extensions_list:
|
||||
if player[controller.controller_type].load(display):
|
||||
self.current_media_players[controller.controller_type] = player[controller.controller_type]
|
||||
if suffix in player.audio_extensions_list:
|
||||
if player.load(display):
|
||||
self.current_media_players[controller.controller_type] = player
|
||||
controller.media_info.media_type = MediaType.Audio
|
||||
return True
|
||||
else:
|
||||
for title in used_players:
|
||||
player = self.media_players[title]
|
||||
if player[controller.controller_type].can_folder:
|
||||
self.resize(display, player[controller.controller_type])
|
||||
if player[controller.controller_type].load(display):
|
||||
self.current_media_players[controller.controller_type] = player[controller.controller_type]
|
||||
if player.can_folder:
|
||||
self.resize(display, player)
|
||||
if player.load(display):
|
||||
self.current_media_players[controller.controller_type] = player
|
||||
controller.media_info.media_type = MediaType.Video
|
||||
return True
|
||||
# no valid player found
|
||||
|
@ -165,7 +165,7 @@ class PlayerTab(SettingsTab):
|
||||
self.player_check_boxes['%s' % player].setEnabled(False)
|
||||
else:
|
||||
self.player_check_boxes['%s' % player].setEnabled(True)
|
||||
self.player_order_list_widget.addItem(self.media_players[player][0].original_name)
|
||||
self.player_order_list_widget.addItem(self.media_players[str(player)].original_name)
|
||||
|
||||
def on_up_button_clicked(self):
|
||||
"""
|
||||
@ -230,14 +230,14 @@ class PlayerTab(SettingsTab):
|
||||
for key, player in self.media_players.items():
|
||||
player = self.media_players[key]
|
||||
checkbox = MediaQCheckBox(self.media_player_group_box)
|
||||
checkbox.setEnabled(player[0].available)
|
||||
checkbox.setObjectName(player[0].name + '_check_box')
|
||||
checkbox.setToolTip(player[0].get_info())
|
||||
checkbox.set_player_name(player[0].name)
|
||||
self.player_check_boxes[player[0].name] = checkbox
|
||||
checkbox.setEnabled(player.available)
|
||||
checkbox.setObjectName(player.name + '_check_box')
|
||||
checkbox.setToolTip(player.get_info())
|
||||
checkbox.set_player_name(player.name)
|
||||
self.player_check_boxes[player.name] = checkbox
|
||||
checkbox.stateChanged.connect(self.on_player_check_box_changed)
|
||||
self.media_player_layout.addWidget(checkbox)
|
||||
if player[0].available and player[0].name in self.used_players:
|
||||
if player.available and player.name in self.used_players:
|
||||
checkbox.setChecked(True)
|
||||
else:
|
||||
checkbox.setChecked(False)
|
||||
@ -250,13 +250,13 @@ class PlayerTab(SettingsTab):
|
||||
"""
|
||||
for key in self.media_players and self.player_check_boxes:
|
||||
player = self.media_players[key]
|
||||
checkbox = self.player_check_boxes[player[0].name]
|
||||
checkbox.set_player_name(player[0].name)
|
||||
if player[0].available:
|
||||
checkbox.setText(player[0].display_name)
|
||||
checkbox = self.player_check_boxes[player.name]
|
||||
checkbox.set_player_name(player.name)
|
||||
if player.available:
|
||||
checkbox.setText(player.display_name)
|
||||
else:
|
||||
checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player[0].display_name
|
||||
if player[0].name == 'vlc':
|
||||
checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name
|
||||
if player.name == 'vlc':
|
||||
checkbox_text += ' ' + translate('OpenLP.PlayerTab',
|
||||
'NOTE: To use VLC you must install the %s version',
|
||||
'Will insert "32bit" or "64bit"') % platform.architecture()[0]
|
||||
|
@ -30,7 +30,7 @@ from openlp.core.common import Registry, RegistryProperties, AppLocation, Settin
|
||||
from openlp.core.lib import ItemCapabilities, MediaManagerItem, MediaType, ServiceItem, ServiceItemContext, \
|
||||
build_icon, check_item_selected
|
||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box, create_horizontal_adjusting_combo_box
|
||||
from openlp.core.ui import DisplayControllerType
|
||||
from openlp.core.ui import DisplayController, DisplayControllerType
|
||||
from openlp.core.ui.media import get_media_players, set_media_players, parse_optical_path, format_milliseconds
|
||||
from openlp.core.utils import get_locale_key
|
||||
from openlp.core.ui.media.vlcplayer import get_vlc
|
||||
@ -81,6 +81,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
# self.display_controller = DisplayController(self.parent())
|
||||
Registry().register_function('video_background_replaced', self.video_background_replaced)
|
||||
Registry().register_function('mediaitem_media_rebuild', self.rebuild_players)
|
||||
# Registry().register_function('config_screen_changed', self.display_setup)
|
||||
# Allow DnD from the desktop
|
||||
self.list_view.activateDnD()
|
||||
|
||||
@ -281,6 +282,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
service_item.title = name
|
||||
service_item.processor = self.display_type_combo_box.currentText()
|
||||
service_item.add_from_command(path, name, CLAPPERBOARD)
|
||||
# Only get start and end times if going to a service
|
||||
if not self.media_controller.media_length(service_item):
|
||||
return False
|
||||
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
|
||||
@ -288,7 +290,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||
if Settings().value(self.settings_section + '/media auto start') == QtCore.Qt.Checked:
|
||||
service_item.will_auto_start = True
|
||||
# force a non-existent theme
|
||||
# force a non-existent theme
|
||||
service_item.theme = -1
|
||||
return True
|
||||
|
||||
@ -311,6 +313,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
' '.join(self.media_controller.video_extensions_list),
|
||||
' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles)
|
||||
|
||||
def display_setup(self):
|
||||
"""
|
||||
Setup media controller display.
|
||||
"""
|
||||
# self.media_controller.setup_display(self.display_controller.preview_display, False)
|
||||
pass
|
||||
|
||||
def populate_display_types(self):
|
||||
"""
|
||||
Load the combobox with the enabled media players, allowing user to select a specific player if settings allow.
|
||||
@ -323,7 +332,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
current_index = 0
|
||||
for player in used_players:
|
||||
# load the drop down selection
|
||||
self.display_type_combo_box.addItem(media_players[player][0].original_name)
|
||||
self.display_type_combo_box.addItem(media_players[player].original_name)
|
||||
if override_player == player:
|
||||
current_index = len(self.display_type_combo_box)
|
||||
if self.display_type_combo_box.count() > 1:
|
||||
@ -385,16 +394,16 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
if item_name:
|
||||
self.list_view.addItem(item_name)
|
||||
|
||||
def get_list(self, media_type=MediaType.Audio):
|
||||
def get_list(self, type=MediaType.Audio):
|
||||
"""
|
||||
Get the list of media, optional select media type.
|
||||
|
||||
:param media_type: Type to get, defaults to audio.
|
||||
:param type: Type to get, defaults to audio.
|
||||
:return: The media list
|
||||
"""
|
||||
media = Settings().value(self.settings_section + '/media files')
|
||||
media.sort(key=lambda filename: get_locale_key(os.path.split(str(filename))[1]))
|
||||
if media_type == MediaType.Audio:
|
||||
if type == MediaType.Audio:
|
||||
extension = self.media_controller.audio_extensions_list
|
||||
else:
|
||||
extension = self.media_controller.video_extensions_list
|
||||
|
Loading…
Reference in New Issue
Block a user