forked from openlp/openlp
OSX: OpenLP does not start without phonon by checking for an import error and disabling the audio player if not available.
bzr-revno: 2490
This commit is contained in:
commit
cf2188a5bb
@ -33,7 +33,12 @@ import cgi
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
|
||||
|
||||
PHONON_AVAILABLE = True
|
||||
try:
|
||||
from PyQt4.phonon import Phonon
|
||||
except ImportError:
|
||||
PHONON_AVAILABLE = False
|
||||
|
||||
from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx
|
||||
from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte
|
||||
@ -139,7 +144,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
||||
self.override = {}
|
||||
self.retranslateUi()
|
||||
self.media_object = None
|
||||
if self.is_live:
|
||||
if self.is_live and PHONON_AVAILABLE:
|
||||
self.audio_player = AudioPlayer(self)
|
||||
else:
|
||||
self.audio_player = None
|
||||
|
@ -580,6 +580,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.display.setup()
|
||||
if self.is_live:
|
||||
self.__add_actions_to_widget(self.display)
|
||||
if self.display.audio_player:
|
||||
self.display.audio_player.connectSlot(QtCore.SIGNAL('tick(qint64)'), self.on_audio_time_remaining)
|
||||
# The SlidePreview's ratio.
|
||||
try:
|
||||
@ -834,6 +835,7 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.slide_list = {}
|
||||
if self.is_live:
|
||||
self.song_menu.menu().clear()
|
||||
if self.display.audio_player:
|
||||
self.display.audio_player.reset()
|
||||
self.set_audio_items_visibility(False)
|
||||
self.audio_pause_item.setChecked(False)
|
||||
@ -843,7 +845,8 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.display.audio_player.add_to_playlist(self.service_item.background_audio)
|
||||
self.track_menu.clear()
|
||||
for counter in range(len(self.service_item.background_audio)):
|
||||
action = self.track_menu.addAction(os.path.basename(self.service_item.background_audio[counter]))
|
||||
action = self.track_menu.addAction(
|
||||
os.path.basename(self.service_item.background_audio[counter]))
|
||||
action.setData(counter)
|
||||
action.triggered.connect(self.on_track_triggered)
|
||||
self.display.audio_player.repeat = \
|
||||
|
@ -479,6 +479,34 @@ class TestSlideController(TestCase):
|
||||
mocked_preview_widget.current_slide_number.assert_called_with()
|
||||
mocked_process_item.assert_called_once_with(mocked_item, 7)
|
||||
|
||||
def on_slide_blank_test(self):
|
||||
"""
|
||||
Test on_slide_blank
|
||||
"""
|
||||
# GIVEN: An instance of SlideController and a mocked on_blank_display
|
||||
slide_controller = SlideController(None)
|
||||
slide_controller.on_blank_display = MagicMock()
|
||||
|
||||
# WHEN: Calling on_slide_blank
|
||||
slide_controller.on_slide_blank()
|
||||
|
||||
# THEN: on_blank_display should have been called with True
|
||||
slide_controller.on_blank_display.assert_called_once_with(True)
|
||||
|
||||
def on_slide_unblank_test(self):
|
||||
"""
|
||||
Test on_slide_unblank
|
||||
"""
|
||||
# GIVEN: An instance of SlideController and a mocked on_blank_display
|
||||
slide_controller = SlideController(None)
|
||||
slide_controller.on_blank_display = MagicMock()
|
||||
|
||||
# WHEN: Calling on_slide_unblank
|
||||
slide_controller.on_slide_unblank()
|
||||
|
||||
# THEN: on_blank_display should have been called with False
|
||||
slide_controller.on_blank_display.assert_called_once_with(False)
|
||||
|
||||
def on_slide_selected_index_no_service_item_test(self):
|
||||
"""
|
||||
Test that when there is no service item, the on_slide_selected_index() method returns immediately
|
||||
|
Loading…
Reference in New Issue
Block a user