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
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon
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

View File

@ -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,26 +835,28 @@ class SlideController(DisplayController, RegistryProperties):
self.slide_list = {}
if self.is_live:
self.song_menu.menu().clear()
self.display.audio_player.reset()
self.set_audio_items_visibility(False)
self.audio_pause_item.setChecked(False)
# If the current item has background audio
if self.service_item.is_capable(ItemCapabilities.HasBackgroundAudio):
self.log_debug('Starting to play...')
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.setData(counter)
action.triggered.connect(self.on_track_triggered)
self.display.audio_player.repeat = \
Settings().value(self.main_window.general_settings_section + '/audio repeat list')
if Settings().value(self.main_window.general_settings_section + '/audio start paused'):
self.audio_pause_item.setChecked(True)
self.display.audio_player.pause()
else:
self.display.audio_player.play()
self.set_audio_items_visibility(True)
if self.display.audio_player:
self.display.audio_player.reset()
self.set_audio_items_visibility(False)
self.audio_pause_item.setChecked(False)
# If the current item has background audio
if self.service_item.is_capable(ItemCapabilities.HasBackgroundAudio):
self.log_debug('Starting to play...')
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.setData(counter)
action.triggered.connect(self.on_track_triggered)
self.display.audio_player.repeat = \
Settings().value(self.main_window.general_settings_section + '/audio repeat list')
if Settings().value(self.main_window.general_settings_section + '/audio start paused'):
self.audio_pause_item.setChecked(True)
self.display.audio_player.pause()
else:
self.display.audio_player.play()
self.set_audio_items_visibility(True)
row = 0
width = self.main_window.control_splitter.sizes()[self.split]
for frame_number, frame in enumerate(self.service_item.get_frames()):

View File

@ -178,7 +178,7 @@ def update_reference_separators():
default_separators = [
'|'.join([
translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
translate('BiblesPlugin', 'v','Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
translate('BiblesPlugin', 'verses',

View File

@ -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