- Fix system player stopping instead of pausing when asked to paused

- Keep position label from causing seek slider and volume slider from jumping
- Fix video backboard not being hidden when switching to next non media slide
- Zero position label when stopping media to match seek sliders behavior
- Use media controller methods to pause and play media when hiding, blanking, and unblanking display to keep UI in sync with media state.
- Fix transparent display on macOS

bzr-revno: 2763
This commit is contained in:
Jonathan Springer 2017-08-27 09:59:51 -07:00 committed by Raoul Snyman
commit f2448ae122
5 changed files with 24 additions and 13 deletions

View File

@ -157,7 +157,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
# platforms. For OpenLP 2.0 keep it only for OS X to not cause any
# regressions on other platforms.
if is_macosx():
window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window
window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window | QtCore.Qt.NoDropShadowWindowHint
self.setWindowFlags(window_flags)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.set_transparency(False)

View File

@ -297,7 +297,9 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
triggers=controller.send_to_plugins)
controller.position_label = QtWidgets.QLabel()
controller.position_label.setText(' 00:00 / 00:00')
controller.position_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
controller.position_label.setToolTip(translate('OpenLP.SlideController', 'Video timer.'))
controller.position_label.setMinimumSize(90, 0)
controller.position_label.setObjectName('position_label')
controller.mediabar.add_toolbar_widget(controller.position_label)
# Build the seek_slider.
@ -433,7 +435,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
log.debug('video mediatype: ' + str(controller.media_info.media_type))
# dont care about actual theme, set a black background
if controller.is_live and not controller.media_info.is_background:
display.frame.evaluateJavaScript('show_video( "setBackBoard", null, null, null,"visible");')
display.frame.evaluateJavaScript('show_video("setBackBoard", null, null,"visible");')
# now start playing - Preview is autoplay!
autoplay = False
# Preview requested
@ -766,6 +768,11 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
self.current_media_players[controller.controller_type].stop(display)
self.current_media_players[controller.controller_type].set_visible(display, False)
controller.seek_slider.setSliderPosition(0)
total_seconds = controller.media_info.length // 1000
total_minutes = total_seconds // 60
total_seconds %= 60
controller.position_label.setText(' %02d:%02d / %02d:%02d' %
(0, 0, total_minutes, total_seconds))
controller.mediabar.actions['playbackPlay'].setVisible(True)
controller.mediabar.actions['playbackStop'].setDisabled(True)
controller.mediabar.actions['playbackPause'].setVisible(False)
@ -828,7 +835,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
display.override = {}
self.current_media_players[controller.controller_type].reset(display)
self.current_media_players[controller.controller_type].set_visible(display, False)
display.frame.evaluateJavaScript('show_video( "setBackBoard", null, null, null,"hidden");')
display.frame.evaluateJavaScript('show_video("setBackBoard", null, null, "hidden");')
del self.current_media_players[controller.controller_type]
def media_hide(self, msg):
@ -843,7 +850,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
display = self._define_display(self.live_controller)
if self.live_controller.controller_type in self.current_media_players and \
self.current_media_players[self.live_controller.controller_type].get_live_state() == MediaState.Playing:
self.current_media_players[self.live_controller.controller_type].pause(display)
self.media_pause(display.controller)
self.current_media_players[self.live_controller.controller_type].set_visible(display, False)
def media_blank(self, msg):
@ -861,7 +868,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
display = self._define_display(self.live_controller)
if self.live_controller.controller_type in self.current_media_players and \
self.current_media_players[self.live_controller.controller_type].get_live_state() == MediaState.Playing:
self.current_media_players[self.live_controller.controller_type].pause(display)
self.media_pause(display.controller)
self.current_media_players[self.live_controller.controller_type].set_visible(display, False)
def media_unblank(self, msg):
@ -879,7 +886,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
if self.live_controller.controller_type in self.current_media_players and \
self.current_media_players[self.live_controller.controller_type].get_live_state() != \
MediaState.Playing:
if self.current_media_players[self.live_controller.controller_type].play(display):
if self.media_play(display.controller):
self.current_media_players[self.live_controller.controller_type].set_visible(display, True)
# Start Timer for ui updates
if not self.live_timer.isActive():

View File

@ -258,7 +258,7 @@ class SystemPlayer(MediaPlayer):
:param display: The display where the media is
"""
if display.media_player.state() == QtMultimedia.QMediaPlayer.PausedState and self.state != MediaState.Paused:
self.stop(display)
self.pause(display)
controller = display.controller
if controller.media_info.end_time > 0:
if display.media_player.position() > controller.media_info.end_time:

View File

@ -154,9 +154,9 @@ class TestMainDisplay(TestCase, TestMixin):
main_display = MainDisplay(display)
# THEN: The window flags should be the same as those needed on Mac OS X.
self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint,
self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint,
main_display.windowFlags(),
'The window flags should be Qt.Window, and Qt.FramelessWindowHint.')
'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.')
@skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.')
def test_macosx_display(self):

View File

@ -402,7 +402,7 @@ class TestSystemPlayer(TestCase):
"""
# GIVEN: A SystemPlayer instance
player = SystemPlayer(self)
player.state = MediaState.Playing
player.state = [MediaState.Playing, MediaState.Playing]
mocked_display = MagicMock()
mocked_display.media_player.state.return_value = QtMultimedia.QMediaPlayer.PausedState
mocked_display.controller.media_info.end_time = 1
@ -415,11 +415,11 @@ class TestSystemPlayer(TestCase):
player.update_ui(mocked_display)
# THEN: The UI is updated
expected_stop_calls = [call(mocked_display), call(mocked_display)]
expected_stop_calls = [call(mocked_display)]
expected_position_calls = [call(), call()]
expected_block_signals_calls = [call(True), call(False)]
mocked_display.media_player.state.assert_called_once_with()
self.assertEqual(2, mocked_stop.call_count)
self.assertEqual(1, mocked_stop.call_count)
self.assertEqual(expected_stop_calls, mocked_stop.call_args_list)
self.assertEqual(2, mocked_display.media_player.position.call_count)
self.assertEqual(expected_position_calls, mocked_display.media_player.position.call_args_list)
@ -442,11 +442,15 @@ class TestSystemPlayer(TestCase):
# THEN: The css should be empty
self.assertEqual('', result)
def test_get_info(self):
@patch('openlp.core.ui.media.systemplayer.QtMultimedia.QMediaPlayer')
def test_get_info(self, MockQMediaPlayer):
"""
Test the get_info() method of the SystemPlayer
"""
# GIVEN: A SystemPlayer instance
mocked_media_player = MagicMock()
mocked_media_player.supportedMimeTypes.return_value = []
MockQMediaPlayer.return_value = mocked_media_player
player = SystemPlayer(self)
# WHEN: get_info() is called