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:
Philip Ridout 2015-01-31 08:18:58 +00:00 committed by Tim Bentley
commit cf2188a5bb
4 changed files with 59 additions and 23 deletions

View File

@ -33,7 +33,12 @@ import cgi
import logging import logging
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
PHONON_AVAILABLE = True
try:
from PyQt4.phonon import Phonon 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.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx
from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte 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.override = {}
self.retranslateUi() self.retranslateUi()
self.media_object = None self.media_object = None
if self.is_live: if self.is_live and PHONON_AVAILABLE:
self.audio_player = AudioPlayer(self) self.audio_player = AudioPlayer(self)
else: else:
self.audio_player = None self.audio_player = None

View File

@ -580,6 +580,7 @@ class SlideController(DisplayController, RegistryProperties):
self.display.setup() self.display.setup()
if self.is_live: if self.is_live:
self.__add_actions_to_widget(self.display) 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) self.display.audio_player.connectSlot(QtCore.SIGNAL('tick(qint64)'), self.on_audio_time_remaining)
# The SlidePreview's ratio. # The SlidePreview's ratio.
try: try:
@ -834,6 +835,7 @@ class SlideController(DisplayController, RegistryProperties):
self.slide_list = {} self.slide_list = {}
if self.is_live: if self.is_live:
self.song_menu.menu().clear() self.song_menu.menu().clear()
if self.display.audio_player:
self.display.audio_player.reset() self.display.audio_player.reset()
self.set_audio_items_visibility(False) self.set_audio_items_visibility(False)
self.audio_pause_item.setChecked(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.display.audio_player.add_to_playlist(self.service_item.background_audio)
self.track_menu.clear() self.track_menu.clear()
for counter in range(len(self.service_item.background_audio)): 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.setData(counter)
action.triggered.connect(self.on_track_triggered) action.triggered.connect(self.on_track_triggered)
self.display.audio_player.repeat = \ self.display.audio_player.repeat = \

View File

@ -479,6 +479,34 @@ class TestSlideController(TestCase):
mocked_preview_widget.current_slide_number.assert_called_with() mocked_preview_widget.current_slide_number.assert_called_with()
mocked_process_item.assert_called_once_with(mocked_item, 7) 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): 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 Test that when there is no service item, the on_slide_selected_index() method returns immediately