← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/bugfixes15 into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/bugfixes15 into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
Related bugs:
  Bug #1422761 in OpenLP: "Traceback when playing media with no players available/enabled"
  https://bugs.launchpad.net/openlp/+bug/1422761

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/bugfixes15/+merge/250532

Don't try to play media if no players are available. Fixes bug 1422761.
Do not display alert on a single screen when 'Display on a single screen' is not checked. Fixes bug 1423956.
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py	2015-01-18 13:39:21 +0000
+++ openlp/core/ui/media/mediacontroller.py	2015-02-21 13:32:10 +0000
@@ -517,6 +517,9 @@
         used_players = get_media_players()[0]
         if service_item.processor != UiStrings().Automatic:
             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 'openlp/plugins/alerts/lib/alertsmanager.py'
--- openlp/plugins/alerts/lib/alertsmanager.py	2015-01-18 13:39:21 +0000
+++ openlp/plugins/alerts/lib/alertsmanager.py	2015-02-21 13:32:10 +0000
@@ -26,7 +26,7 @@
 
 from PyQt4 import QtCore
 
-from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, translate
+from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, Settings, translate
 
 
 class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties):
@@ -70,7 +70,8 @@
         """
         Format and request the Alert and start the timer.
         """
-        if not self.alert_list:
+        if not self.alert_list or (self.live_controller.display.screens.display_count == 1 
+                                   and not Settings().value('core/display on monitor')):
             return
         text = self.alert_list.pop(0)
         alert_tab = self.parent().settings_tab

=== modified file 'tests/functional/openlp_core_ui_media/test_mediacontroller.py'
--- tests/functional/openlp_core_ui_media/test_mediacontroller.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_ui_media/test_mediacontroller.py	2015-02-21 13:32:10 +0000
@@ -28,7 +28,7 @@
 from openlp.core.ui.media.mediaplayer import MediaPlayer
 from openlp.core.common import Registry
 
-from tests.functional import MagicMock
+from tests.functional import MagicMock, patch
 from tests.helpers.testmixin import TestMixin
 
 
@@ -58,3 +58,26 @@
                              'Video extensions should be the same')
         self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
                              'Audio extensions should be the same')
+
+    def check_file_type_no_players_test(self):
+        """
+        Test that we don't try to play media when no players available
+        """
+        # GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
+        with patch('openlp.core.ui.media.mediacontroller.get_media_players') as mocked_get_media_players,\
+                patch('openlp.core.ui.media.mediacontroller.UiStrings') as mocked_uistrings:
+            mocked_get_media_players.return_value = ([], '')
+            mocked_ret_uistrings = MagicMock()
+            mocked_ret_uistrings.Automatic = 1
+            mocked_uistrings.return_value = mocked_ret_uistrings
+            media_controller = MediaController()
+            mocked_controller = MagicMock()
+            mocked_display = MagicMock()
+            mocked_service_item = MagicMock()
+            mocked_service_item.processor = 1
+
+            # WHEN: calling _check_file_type when no players exists
+            ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
+
+            # THEN: it should return False
+            self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.')


Follow ups