openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #27948
[Merge] lp:~springermac/openlp/fix-media into lp:openlp
Jonathan Springer has proposed merging lp:~springermac/openlp/fix-media into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~springermac/openlp/fix-media/+merge/279824
Fix traceback in mediacontroller if a service item had a processor type of automatic
--
Your team OpenLP Core is requested to review the proposed merge of lp:~springermac/openlp/fix-media into lp:openlp.
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2015-11-28 15:37:26 +0000
+++ openlp/core/ui/media/mediacontroller.py 2015-12-07 21:43:24 +0000
@@ -514,7 +514,10 @@
:param display: Which display to use
:param service_item: The ServiceItem containing the details to be played.
"""
- used_players = get_media_players()
+ used_players = get_media_players()[0]
+ # If no player, we can't play
+ if not used_players:
+ return False
default_player = used_players[0]
if service_item.processor and service_item.processor != UiStrings().Automatic:
# check to see if the player is usable else use the default one.
@@ -522,9 +525,6 @@
used_players = default_player
else:
used_players = [service_item.processor.lower()]
- # If no player, we can't play
- if not used_players:
- return False
if controller.media_info.file_info.isFile():
suffix = '*.%s' % controller.media_info.file_info.suffix().lower()
for title in used_players:
=== modified file 'tests/functional/openlp_core_ui_media/test_mediacontroller.py'
--- tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-05-29 21:01:44 +0000
+++ tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-12-07 21:43:24 +0000
@@ -120,6 +120,36 @@
# THEN: it should return False
self.assertFalse(ret, '_check_file_type should return False when the processor for service_item is None.')
+ @patch('openlp.core.ui.media.mediacontroller.get_media_players')
+ @patch('openlp.core.ui.media.mediacontroller.UiStrings')
+ def check_file_type_automatic_processor_test(self, mocked_uistrings, mocked_get_media_players):
+ """
+ Test that we can play media when players are available and we have a automatic processor from the service item
+ """
+ # GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
+ mocked_get_media_players.return_value = (['vlc', 'webkit'], '')
+ mocked_ret_uistrings = MagicMock()
+ mocked_ret_uistrings.Automatic = 1
+ mocked_uistrings.return_value = mocked_ret_uistrings
+ media_controller = MediaController()
+ mocked_vlc = MagicMock()
+ mocked_vlc.video_extensions_list = ['*.mp4']
+ media_controller.media_players = {'vlc': mocked_vlc, 'webkit': MagicMock()}
+ mocked_controller = MagicMock()
+ mocked_suffix = MagicMock()
+ mocked_suffix.return_value = 'mp4'
+ mocked_controller.media_info.file_info.suffix = mocked_suffix
+ mocked_display = MagicMock()
+ mocked_service_item = MagicMock()
+ mocked_service_item.processor = 1
+
+ # WHEN: calling _check_file_type when the processor for the service item is None
+ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
+
+ # THEN: it should return False
+ self.assertTrue(ret, '_check_file_type should return True when mediaplayers are available and '
+ 'the service item has an automatic processor.')
+
def media_play_msg_test(self):
"""
Test that the media controller responds to the request to play a loaded video
References