forked from openlp/openlp
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. bzr-revno: 2510 Fixes: https://launchpad.net/bugs/1422761, https://launchpad.net/bugs/1423956
This commit is contained in:
commit
66b898f2c3
|
@ -517,6 +517,9 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
|
|||
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:
|
||||
|
|
|
@ -26,7 +26,7 @@ displaying of alerts.
|
|||
|
||||
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 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperti
|
|||
"""
|
||||
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
|
||||
|
|
|
@ -28,7 +28,7 @@ from openlp.core.ui.media.mediacontroller import MediaController
|
|||
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 @@ class TestMediaController(TestCase, TestMixin):
|
|||
'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.')
|
||||
|
|
Loading…
Reference in New Issue