From c901ec3d75ed82c12870ff300860c058fcabf5e0 Mon Sep 17 00:00:00 2001 From: Phill Date: Fri, 24 May 2019 23:11:11 +0100 Subject: [PATCH 1/7] Move suffixes from list to set, remove VlcPlayer.is_active as it was never ser --- openlp/core/lib/serviceitem.py | 8 +++++--- openlp/core/ui/media/mediacontroller.py | 18 ++++++++---------- openlp/core/ui/media/mediaplayer.py | 1 - openlp/core/ui/servicemanager.py | 16 ++++++++-------- .../ui/media/test_mediacontroller.py | 1 - 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index f284f59bb..3366cd858 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -593,9 +593,11 @@ class ServiceItem(RegistryProperties): """ return not bool(self.slides) - def validate_item(self, suffix_list=None): + def validate_item(self, suffixes=None): """ Validates a service item to make sure it is valid + + :param set[str] suffixes: A set of vaild suffixes """ self.is_valid = True for slide in self.slides: @@ -612,8 +614,8 @@ class ServiceItem(RegistryProperties): if not os.path.exists(file_name): self.is_valid = False break - if suffix_list and not self.is_text(): + if suffixes and not self.is_text(): file_suffix = slide['title'].split('.')[-1] - if file_suffix.lower() not in suffix_list: + if file_suffix.lower() not in suffixes: self.is_valid = False break diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 69fee7189..4cb2a8e79 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -104,17 +104,15 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): """ suffix_list = [] self.audio_extensions_list = [] - if self.vlc_player.is_active: - for item in self.vlc_player.audio_extensions_list: - if item not in self.audio_extensions_list: - self.audio_extensions_list.append(item) - suffix_list.append(item[2:]) + for item in self.vlc_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 = [] - if self.vlc_player.is_active: - for item in self.vlc_player.video_extensions_list: - if item not in self.video_extensions_list: - self.video_extensions_list.append(item) - suffix_list.append(item[2:]) + for item in self.vlc_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 bootstrap_initialise(self): diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index f4bc4a1df..9eb186665 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -38,7 +38,6 @@ class MediaPlayer(RegistryProperties): self.parent = parent self.name = name self.available = self.check_available() - self.is_active = False self.can_background = False self.can_folder = False self.state = {0: MediaState.Off, 1: MediaState.Off} diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5e8b3e0cd..9e8b915fb 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -320,7 +320,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi """ super().__init__(parent) self.service_items = [] - self.suffixes = [] + self.suffixes = set() self.drop_position = -1 self.service_id = 0 # is a new service and has not been saved @@ -403,20 +403,18 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi Resets the Suffixes list. """ - self.suffixes = [] + self.suffixes.clear() def supported_suffixes(self, suffix_list): """ Adds Suffixes supported to the master list. Called from Plugins. - :param suffix_list: New Suffix's to be supported + :param list[str] | str suffix_list: New suffix(s) to be supported """ if isinstance(suffix_list, str): - self.suffixes.append(suffix_list) + self.suffixes.add(suffix_list) else: - for suffix in suffix_list: - if suffix not in self.suffixes: - self.suffixes.append(suffix) + self.suffixes.update(suffix_list) def on_new_service_clicked(self): """ @@ -475,9 +473,11 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Save) - def on_recent_service_clicked(self): + def on_recent_service_clicked(self, checked): """ Load a recent file as the service triggered by mainwindow recent service list. + + :param bool checked: Not used """ if self.is_modified(): result = self.save_modified_service() diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index e6209cd37..a1a1122a1 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -50,7 +50,6 @@ class TestMediaController(TestCase, TestMixin): # GIVEN: A MediaController and an active player with audio and video extensions media_controller = MediaController() media_controller.vlc_player = VlcPlayer(None) - media_controller.vlc_player.is_active = True media_controller.vlc_player.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg'] media_controller.vlc_player.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm'] From c2550777c3f8f9940e75977c7d268445939898e3 Mon Sep 17 00:00:00 2001 From: Phill Date: Sun, 26 May 2019 11:30:37 +0100 Subject: [PATCH 2/7] VLC extension tidyups --- openlp/core/common/json.py | 1 - openlp/core/lib/mediamanageritem.py | 4 +-- openlp/core/ui/media/mediacontroller.py | 32 +++---------------- openlp/core/ui/media/mediaplayer.py | 2 -- openlp/core/ui/media/vlcplayer.py | 2 -- openlp/core/ui/themeform.py | 1 - openlp/plugins/media/lib/mediaitem.py | 10 +++--- openlp/plugins/songs/lib/openlyricsexport.py | 2 +- .../openlp_core/common/test_path.py | 1 - .../ui/media/test_mediacontroller.py | 19 ----------- .../openlp_core/ui/media/test_vlcplayer.py | 2 -- 11 files changed, 13 insertions(+), 63 deletions(-) diff --git a/openlp/core/common/json.py b/openlp/core/common/json.py index 6f815aefa..4a54e41b3 100644 --- a/openlp/core/common/json.py +++ b/openlp/core/common/json.py @@ -23,7 +23,6 @@ from contextlib import suppress from json import JSONDecoder, JSONEncoder from pathlib import Path - _registered_classes = {} diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 59cb1cdcf..eee11b970 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -589,7 +589,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): """ Add this item to the current service. - :param item: Item to be processed + :param QtWidgets.QListWidgetItem | QtWidgets.QTreeWidgetItem | None item: Item to be processed :param replace: Replace the existing item :param remote: Triggered from remote :param position: Position to place item @@ -627,7 +627,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): def build_service_item(self, item=None, remote=False, context=ServiceItemContext.Live): """ Common method for generating a service item - :param item: Service Item to be built. + :param QtWidgets.QListWidgetItem | QtWidgets.QTreeWidgetItem | None item: Service Item to be built. :param remote: Remote triggered (False) :param context: The context on which this is called """ diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 4cb2a8e79..4f4400f81 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -44,7 +44,7 @@ from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import DisplayControllerType from openlp.core.ui.media import MediaState, ItemMediaInfo, MediaType, parse_optical_path from openlp.core.ui.media.endpoint import media_endpoint -from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc +from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, VlcPlayer, get_vlc log = logging.getLogger(__name__) @@ -65,11 +65,6 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): current_media_players is an array of player instances keyed on ControllerType. """ - def __init__(self, parent=None): - """ - Constructor - """ - super(MediaController, self).__init__(parent) def setup(self): self.vlc_player = None @@ -95,26 +90,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): Registry().register_function('songs_hide', self.media_hide) Registry().register_function('songs_blank', self.media_blank) Registry().register_function('songs_unblank', self.media_unblank) - Registry().register_function('mediaitem_suffixes', self._generate_extensions_lists) register_endpoint(media_endpoint) - def _generate_extensions_lists(self): - """ - Set the active players and available media files - """ - suffix_list = [] - self.audio_extensions_list = [] - for item in self.vlc_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 item in self.vlc_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 bootstrap_initialise(self): """ Check to see if we have any media Player's available. @@ -129,7 +106,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): else: State().missing_text('media_live', translate('OpenLP.SlideController', 'VLC or pymediainfo are missing, so you are unable to play any media')) - self._generate_extensions_lists() + self.service_manager.supported_suffixes(ext[2:] for ext in AUDIO_EXT) + self.service_manager.supported_suffixes(ext[2:] for ext in VIDEO_EXT) return True def bootstrap_post_set_up(self): @@ -379,7 +357,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): if file.is_file: suffix = '*%s' % file.suffix.lower() file = str(file) - if suffix in self.vlc_player.video_extensions_list: + if suffix in VIDEO_EXT: if not controller.media_info.is_background or controller.media_info.is_background and \ self.vlc_player.can_background: self.resize(display, self.vlc_player) @@ -387,7 +365,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): self.current_media_players[controller.controller_type] = self.vlc_player controller.media_info.media_type = MediaType.Video return True - if suffix in self.vlc_player.audio_extensions_list: + if suffix in AUDIO_EXT: if self.vlc_player.load(display, file): self.current_media_players[controller.controller_type] = self.vlc_player controller.media_info.media_type = MediaType.Audio diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 9eb186665..3c0b7e873 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -42,8 +42,6 @@ class MediaPlayer(RegistryProperties): self.can_folder = False self.state = {0: MediaState.Off, 1: MediaState.Off} self.has_own_widget = False - self.audio_extensions_list = [] - self.video_extensions_list = [] def check_available(self): """ diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6ba27998b..3f7deac75 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -109,8 +109,6 @@ class VlcPlayer(MediaPlayer): self.display_name = '&VLC' self.parent = parent self.can_folder = True - self.audio_extensions_list = AUDIO_EXT - self.video_extensions_list = VIDEO_EXT def setup(self, output_display, live_display): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 0dfb53aab..7394409fa 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -32,7 +32,6 @@ from openlp.core.common.mixins import RegistryProperties from openlp.core.common.registry import Registry from openlp.core.lib.theme import BackgroundGradientType, BackgroundType from openlp.core.lib.ui import critical_error_message_box -# TODO: Fix this. Use a "get_video_extensions" method which uses the current media player from openlp.core.ui.media.vlcplayer import VIDEO_EXT from openlp.core.ui.themelayoutform import ThemeLayoutForm from openlp.core.ui.themewizard import Ui_ThemeWizard diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 658773b99..2d66eabe9 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -38,7 +38,7 @@ from openlp.core.lib.serviceitem import ItemCapabilities from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.icons import UiIcons from openlp.core.ui.media import parse_optical_path, format_milliseconds -from openlp.core.ui.media.vlcplayer import get_vlc +from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, get_vlc if get_vlc() is not None: @@ -233,8 +233,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): # self.populate_display_types() self.on_new_file_masks = translate('MediaPlugin.MediaItem', 'Videos ({video});;Audio ({audio});;{files} ' - '(*)').format(video=' '.join(self.media_controller.video_extensions_list), - audio=' '.join(self.media_controller.audio_extensions_list), + '(*)').format(video=' '.join(VIDEO_EXT), + audio=' '.join(AUDIO_EXT), files=UiStrings().AllFiles) def on_delete_click(self): @@ -301,9 +301,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): media_file_paths = Settings().value(self.settings_section + '/media files') media_file_paths.sort(key=lambda file_path: get_natural_key(file_path.name)) if media_type == MediaType.Audio: - extension = self.media_controller.audio_extensions_list + extension = AUDIO_EXT else: - extension = self.media_controller.video_extensions_list + extension = VIDEO_EXT # TODO: Rename extension to extensions extension = [x[1:] for x in extension] media = [x for x in media_file_paths if x.suffix in extension] return media diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 311bfa711..37a64162f 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -43,7 +43,7 @@ class OpenLyricsExport(RegistryProperties): """ def __init__(self, parent, songs, save_path): """ - Initialise the export. + Initialise the export :param pathlib.Path save_path: The directory to save the exported songs in :rtype: None diff --git a/tests/functional/openlp_core/common/test_path.py b/tests/functional/openlp_core/common/test_path.py index 55b5b70de..5b983bc20 100644 --- a/tests/functional/openlp_core/common/test_path.py +++ b/tests/functional/openlp_core/common/test_path.py @@ -22,7 +22,6 @@ """ Package to test the openlp.core.common.path package. """ -# TODO: fix patches import os from pathlib import Path from unittest import TestCase diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index a1a1122a1..2389d8a34 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -43,25 +43,6 @@ class TestMediaController(TestCase, TestMixin): Registry.create() Registry().register('service_manager', MagicMock()) - def test_generate_extensions_lists(self): - """ - Test that the extensions are create correctly - """ - # GIVEN: A MediaController and an active player with audio and video extensions - media_controller = MediaController() - media_controller.vlc_player = VlcPlayer(None) - media_controller.vlc_player.audio_extensions_list = ['*.mp3', '*.wav', '*.wma', '*.ogg'] - media_controller.vlc_player.video_extensions_list = ['*.mp4', '*.mov', '*.avi', '*.ogm'] - - # WHEN: calling _generate_extensions_lists - media_controller._generate_extensions_lists() - - # THEN: extensions list should have been copied from the player to the mediacontroller - assert media_controller.video_extensions_list == media_controller.video_extensions_list, \ - 'Video extensions should be the same' - assert media_controller.audio_extensions_list == media_controller.audio_extensions_list, \ - 'Audio extensions should be the same' - def test_resize(self): """ Test that the resize method is called correctly diff --git a/tests/functional/openlp_core/ui/media/test_vlcplayer.py b/tests/functional/openlp_core/ui/media/test_vlcplayer.py index d3de03758..75828de8d 100644 --- a/tests/functional/openlp_core/ui/media/test_vlcplayer.py +++ b/tests/functional/openlp_core/ui/media/test_vlcplayer.py @@ -95,8 +95,6 @@ class TestVLCPlayer(TestCase, TestMixin): assert '&VLC' == vlc_player.display_name assert vlc_player.parent is None assert vlc_player.can_folder is True - assert AUDIO_EXT == vlc_player.audio_extensions_list - assert VIDEO_EXT == vlc_player.video_extensions_list @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') From cdf29876e25792150b5b11b359128033544ff656 Mon Sep 17 00:00:00 2001 From: Phill Date: Sun, 26 May 2019 21:53:54 +0100 Subject: [PATCH 3/7] More media clean-up --- openlp/core/ui/media/mediacontroller.py | 4 +-- openlp/core/ui/media/mediaplayer.py | 6 ---- openlp/core/ui/media/vlcplayer.py | 33 ++++++------------- openlp/core/ui/themeform.py | 5 ++- .../openlp_core/ui/media/test_vlcplayer.py | 17 ---------- 5 files changed, 14 insertions(+), 51 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 4f4400f81..a17e48ea9 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -106,8 +106,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): else: State().missing_text('media_live', translate('OpenLP.SlideController', 'VLC or pymediainfo are missing, so you are unable to play any media')) - self.service_manager.supported_suffixes(ext[2:] for ext in AUDIO_EXT) - self.service_manager.supported_suffixes(ext[2:] for ext in VIDEO_EXT) + self.service_manager.supported_suffixes(AUDIO_EXT) + self.service_manager.supported_suffixes(VIDEO_EXT) return True def bootstrap_post_set_up(self): diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 3c0b7e873..be88ab549 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -163,12 +163,6 @@ class MediaPlayer(RegistryProperties): """ return '' - def get_info(self): - """ - Returns Information about the player - """ - return '' - def get_live_state(self): """ Get the state of the live player diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 3f7deac75..da4036bda 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -42,20 +42,18 @@ from openlp.core.ui.media.mediaplayer import MediaPlayer log = logging.getLogger(__name__) # Audio and video extensions copied from 'include/vlc_interface.h' from vlc 2.2.0 source -AUDIO_EXT = ['*.3ga', '*.669', '*.a52', '*.aac', '*.ac3', '*.adt', '*.adts', '*.aif', '*.aifc', '*.aiff', '*.amr', - '*.aob', '*.ape', '*.awb', '*.caf', '*.dts', '*.flac', '*.it', '*.kar', '*.m4a', '*.m4b', '*.m4p', '*.m5p', - '*.mid', '*.mka', '*.mlp', '*.mod', '*.mpa', '*.mp1', '*.mp2', '*.mp3', '*.mpc', '*.mpga', '*.mus', - '*.oga', '*.ogg', '*.oma', '*.opus', '*.qcp', '*.ra', '*.rmi', '*.s3m', '*.sid', '*.spx', '*.thd', '*.tta', - '*.voc', '*.vqf', '*.w64', '*.wav', '*.wma', '*.wv', '*.xa', '*.xm'] +AUDIO_EXT = ('3ga', '669', 'a52', 'aac', 'ac3', 'adt', 'adts', 'aif', 'aifc', 'aiff', 'amr', 'aob', 'ape', 'awb', 'caf', + 'dts', 'flac', 'it', 'kar', 'm4a', 'm4b', 'm4p', 'm5p', 'mid', 'mka', 'mlp', 'mod', 'mpa', 'mp1', 'mp2', + 'mp3', 'mpc', 'mpga', 'mus', 'oga', 'ogg', 'oma', 'opus', 'qcp', 'ra', 'rmi', 's3m', 'sid', 'spx', 'thd', + 'tta', 'voc', 'vqf', 'w64', 'wav', 'wma', 'wv', 'xa', 'xm') -VIDEO_EXT = ['*.3g2', '*.3gp', '*.3gp2', '*.3gpp', '*.amv', '*.asf', '*.avi', '*.bik', '*.divx', '*.drc', '*.dv', - '*.f4v', '*.flv', '*.gvi', '*.gxf', '*.iso', '*.m1v', '*.m2v', '*.m2t', '*.m2ts', '*.m4v', '*.mkv', - '*.mov', '*.mp2', '*.mp2v', '*.mp4', '*.mp4v', '*.mpe', '*.mpeg', '*.mpeg1', '*.mpeg2', '*.mpeg4', '*.mpg', - '*.mpv2', '*.mts', '*.mtv', '*.mxf', '*.mxg', '*.nsv', '*.nuv', '*.ogg', '*.ogm', '*.ogv', '*.ogx', '*.ps', - '*.rec', '*.rm', '*.rmvb', '*.rpl', '*.thp', '*.tod', '*.ts', '*.tts', '*.txd', '*.vob', '*.vro', '*.webm', - '*.wm', '*.wmv', '*.wtv', '*.xesc', +VIDEO_EXT = ('3g2', '3gp', '3gp2', '3gpp', 'amv', 'asf', 'avi', 'bik', 'divx', 'drc', 'dv', 'f4v', 'flv', 'gvi', 'gxf', + 'iso', 'm1v', 'm2v', 'm2t', 'm2ts', 'm4v', 'mkv', 'mov', 'mp2', 'mp2v', 'mp4', 'mp4v', 'mpe', 'mpeg', + 'mpeg1', 'mpeg2', 'mpeg4', 'mpg', 'mpv2', 'mts', 'mtv', 'mxf', 'mxg', 'nsv', 'nuv', 'ogg', 'ogm', 'ogv', + 'ogx', 'ps', 'rec', 'rm', 'rmvb', 'rpl', 'thp', 'tod', 'ts', 'tts', 'txd', 'vob', 'vro', 'webm', 'wm', + 'wmv', 'wtv', 'xesc', # These extensions was not in the official list, added manually. - '*.nut', '*.rv', '*.xvid'] + 'nut', 'rv', 'xvid') def get_vlc(): @@ -372,14 +370,3 @@ class VlcPlayer(MediaPlayer): else: controller.seek_slider.setSliderPosition(output_display.vlc_media_player.get_time()) controller.seek_slider.blockSignals(False) - - def get_info(self): - """ - Return some information about this player - """ - return(translate('Media.player', 'VLC is an external player which ' - 'supports a number of different formats.') + - '
' + translate('Media.player', 'Audio') + - '
' + str(AUDIO_EXT) + '
' + - translate('Media.player', 'Video') + '
' + - str(VIDEO_EXT) + '
') diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 7394409fa..f165d32dc 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -75,9 +75,8 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties): self.image_path_edit.filters = \ '{name};;{text} (*)'.format(name=get_images_filter(), text=UiStrings().AllFiles) self.image_path_edit.pathChanged.connect(self.on_image_path_edit_path_changed) - # TODO: Should work - visible_formats = '({name})'.format(name='; '.join(VIDEO_EXT)) - actual_formats = '({name})'.format(name=' '.join(VIDEO_EXT)) + visible_formats = '(*.{name})'.format(name='; *.'.join(VIDEO_EXT)) + actual_formats = '(*.{name})'.format(name=' *.'.join(VIDEO_EXT)) video_filter = '{trans} {visible} {actual}'.format(trans=translate('OpenLP', 'Video Files'), visible=visible_formats, actual=actual_formats) self.video_path_edit.filters = '{video};;{ui} (*)'.format(video=video_filter, ui=UiStrings().AllFiles) diff --git a/tests/functional/openlp_core/ui/media/test_vlcplayer.py b/tests/functional/openlp_core/ui/media/test_vlcplayer.py index 75828de8d..ace896066 100644 --- a/tests/functional/openlp_core/ui/media/test_vlcplayer.py +++ b/tests/functional/openlp_core/ui/media/test_vlcplayer.py @@ -956,20 +956,3 @@ class TestVLCPlayer(TestCase, TestMixin): mocked_controller.seek_slider.setSliderPosition.assert_called_with(300) expected_calls = [call(True), call(False)] assert expected_calls == mocked_controller.seek_slider.blockSignals.call_args_list - - @patch('openlp.core.ui.media.vlcplayer.translate') - def test_get_info(self, mocked_translate): - """ - Test that get_info() returns some information about the VLC player - """ - # GIVEN: A VlcPlayer - mocked_translate.side_effect = lambda *x: x[1] - vlc_player = VlcPlayer(None) - - # WHEN: get_info() is run - info = vlc_player.get_info() - - # THEN: The information should be correct - assert 'VLC is an external player which supports a number of different formats.
' \ - 'Audio
' + str(AUDIO_EXT) + '
Video
' + \ - str(VIDEO_EXT) + '
' == info From f4111e4431edad7122ae33c56a4049edd0cf44c4 Mon Sep 17 00:00:00 2001 From: Phill Date: Fri, 31 May 2019 20:59:38 +0100 Subject: [PATCH 4/7] Fix up filters --- openlp/plugins/media/lib/mediaitem.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 2d66eabe9..f1801b7a2 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -232,9 +232,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): """ # self.populate_display_types() self.on_new_file_masks = translate('MediaPlugin.MediaItem', - 'Videos ({video});;Audio ({audio});;{files} ' - '(*)').format(video=' '.join(VIDEO_EXT), - audio=' '.join(AUDIO_EXT), + 'Videos (*.{video});;Audio (*.{audio});;{files} ' + '(*)').format(video=' *.'.join(VIDEO_EXT), + audio=' *.'.join(AUDIO_EXT), files=UiStrings().AllFiles) def on_delete_click(self): From 8fe469aca3c4c2ccebcf6d94f01f2b3c5159f004 Mon Sep 17 00:00:00 2001 From: Phill Date: Fri, 31 May 2019 21:04:51 +0100 Subject: [PATCH 5/7] Re-add period --- openlp/plugins/songs/lib/openlyricsexport.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 37a64162f..311bfa711 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -43,7 +43,7 @@ class OpenLyricsExport(RegistryProperties): """ def __init__(self, parent, songs, save_path): """ - Initialise the export + Initialise the export. :param pathlib.Path save_path: The directory to save the exported songs in :rtype: None From 52eb196e5b08d02bda775ccc7b84cf7ed4a6e565 Mon Sep 17 00:00:00 2001 From: Phill Date: Fri, 31 May 2019 21:19:15 +0100 Subject: [PATCH 6/7] PEP8 --- openlp/core/ui/media/vlcplayer.py | 5 ++--- .../functional/openlp_core/ui/media/test_mediacontroller.py | 1 - tests/functional/openlp_core/ui/media/test_vlcplayer.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index da4036bda..3904b63ae 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -33,7 +33,6 @@ import vlc from PyQt5 import QtWidgets from openlp.core.common import is_linux, is_macosx, is_win -from openlp.core.common.i18n import translate from openlp.core.common.settings import Settings from openlp.core.ui.media import MediaState, MediaType from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -49,8 +48,8 @@ AUDIO_EXT = ('3ga', '669', 'a52', 'aac', 'ac3', 'adt', 'adts', 'aif', 'aifc', 'a VIDEO_EXT = ('3g2', '3gp', '3gp2', '3gpp', 'amv', 'asf', 'avi', 'bik', 'divx', 'drc', 'dv', 'f4v', 'flv', 'gvi', 'gxf', 'iso', 'm1v', 'm2v', 'm2t', 'm2ts', 'm4v', 'mkv', 'mov', 'mp2', 'mp2v', 'mp4', 'mp4v', 'mpe', 'mpeg', - 'mpeg1', 'mpeg2', 'mpeg4', 'mpg', 'mpv2', 'mts', 'mtv', 'mxf', 'mxg', 'nsv', 'nuv', 'ogg', 'ogm', 'ogv', - 'ogx', 'ps', 'rec', 'rm', 'rmvb', 'rpl', 'thp', 'tod', 'ts', 'tts', 'txd', 'vob', 'vro', 'webm', 'wm', + 'mpeg1', 'mpeg2', 'mpeg4', 'mpg', 'mpv2', 'mts', 'mtv', 'mxf', 'mxg', 'nsv', 'nuv', 'ogg', 'ogm', 'ogv', + 'ogx', 'ps', 'rec', 'rm', 'rmvb', 'rpl', 'thp', 'tod', 'ts', 'tts', 'txd', 'vob', 'vro', 'webm', 'wm', 'wmv', 'wtv', 'xesc', # These extensions was not in the official list, added manually. 'nut', 'rv', 'xvid') diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index 2389d8a34..b0e41c19c 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -27,7 +27,6 @@ from unittest.mock import MagicMock, patch from openlp.core.common.registry import Registry from openlp.core.ui.media.mediacontroller import MediaController -from openlp.core.ui.media.vlcplayer import VlcPlayer from tests.helpers.testmixin import TestMixin from tests.utils.constants import RESOURCE_PATH diff --git a/tests/functional/openlp_core/ui/media/test_vlcplayer.py b/tests/functional/openlp_core/ui/media/test_vlcplayer.py index ace896066..9eaeb21a6 100644 --- a/tests/functional/openlp_core/ui/media/test_vlcplayer.py +++ b/tests/functional/openlp_core/ui/media/test_vlcplayer.py @@ -30,7 +30,7 @@ from unittest.mock import MagicMock, call, patch from openlp.core.common.registry import Registry from openlp.core.ui.media import MediaState, MediaType -from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT, VlcPlayer, get_vlc +from openlp.core.ui.media.vlcplayer import VlcPlayer, get_vlc from tests.helpers import MockDateTime from tests.helpers.testmixin import TestMixin From aaaab9bf43a4e4d59bac4d941bab8286ad29871e Mon Sep 17 00:00:00 2001 From: Phill Date: Sat, 1 Jun 2019 07:59:45 +0100 Subject: [PATCH 7/7] Add media extensions in the service manager --- openlp/core/ui/media/mediacontroller.py | 2 -- openlp/core/ui/servicemanager.py | 10 +++++++++- openlp/plugins/media/lib/mediaitem.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index a17e48ea9..27164a06a 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -106,8 +106,6 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): else: State().missing_text('media_live', translate('OpenLP.SlideController', 'VLC or pymediainfo are missing, so you are unable to play any media')) - self.service_manager.supported_suffixes(AUDIO_EXT) - self.service_manager.supported_suffixes(VIDEO_EXT) return True def bootstrap_post_set_up(self): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 9e8b915fb..220998c59 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -48,6 +48,7 @@ from openlp.core.lib.plugin import PluginStatus from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem from openlp.core.lib.ui import create_widget_action, critical_error_message_box, find_and_set_in_combo_box from openlp.core.ui.icons import UiIcons +from openlp.core.ui.media.vlcplayer import AUDIO_EXT, VIDEO_EXT from openlp.core.ui.serviceitemeditform import ServiceItemEditForm from openlp.core.ui.servicenoteform import ServiceNoteForm from openlp.core.ui.starttimeform import StartTimeForm @@ -321,6 +322,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi super().__init__(parent) self.service_items = [] self.suffixes = set() + self.add_media_suffixes() self.drop_position = -1 self.service_id = 0 # is a new service and has not been saved @@ -347,6 +349,13 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi self.service_item_edit_form = ServiceItemEditForm() self.start_time_form = StartTimeForm() + def add_media_suffixes(self): + """ + Add the suffixes supported by :mod:`openlp.core.ui.media.vlcplayer` + """ + self.suffixes.update(AUDIO_EXT) + self.suffixes.update(VIDEO_EXT) + def set_modified(self, modified=True): """ Setter for property "modified". Sets whether or not the current service has been modified. @@ -401,7 +410,6 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi def reset_supported_suffixes(self): """ Resets the Suffixes list. - """ self.suffixes.clear() diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index f1801b7a2..58994a909 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -303,7 +303,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): if media_type == MediaType.Audio: extension = AUDIO_EXT else: - extension = VIDEO_EXT # TODO: Rename extension to extensions + extension = VIDEO_EXT extension = [x[1:] for x in extension] media = [x for x in media_file_paths if x.suffix in extension] return media