From 762b9fba4e91bbbd1bd527a26cbb5144ec58b1ad Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:16:20 -0400 Subject: [PATCH 01/10] Fix system player stopping instead of pausing when asked to paused --- openlp/core/ui/media/systemplayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/systemplayer.py b/openlp/core/ui/media/systemplayer.py index 6209e218a..52ad1e749 100644 --- a/openlp/core/ui/media/systemplayer.py +++ b/openlp/core/ui/media/systemplayer.py @@ -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: From 37c3f96885e9ef2e885bf690241e5268d64f152b Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:26:14 -0400 Subject: [PATCH 02/10] Keep position label from causing seek slider and volume slider from jumping --- openlp/core/ui/media/mediacontroller.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 13bdf3bd5..3f4bd2fd0 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -294,7 +294,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. From 5b9171866b1ee688ed55ae77ae4c54dcda362ee2 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:27:42 -0400 Subject: [PATCH 03/10] Fix video backboard not being hidden when switching to next non media slide --- openlp/core/ui/media/mediacontroller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 3f4bd2fd0..550d83b0f 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -432,7 +432,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 @@ -802,7 +802,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): From e9d41ebc6eaa7cd45b5b6cb162145a4adacf8b2b Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:29:15 -0400 Subject: [PATCH 04/10] Zero position label when stopping media to match seek sliders behavior --- openlp/core/ui/media/mediacontroller.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 550d83b0f..8178e0ced 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -740,6 +740,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) From fdcb8ae0c7c9a1d7dcc0c133d79621b1d16f63ff Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:31:14 -0400 Subject: [PATCH 05/10] Use media controller methods to pause and play media when hiding, blanking, and unblanking display to keep UI in sync with media state. --- openlp/core/ui/media/mediacontroller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 8178e0ced..1723105a8 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -822,7 +822,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): @@ -840,7 +840,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): @@ -858,7 +858,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(): From 9d43c19a036d76ec31d7d84d051dbd5031034603 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 12:33:22 -0400 Subject: [PATCH 06/10] Fix transparent display on macOS --- openlp/core/ui/maindisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a40ade826..439d87a8d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -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) From 238475845fe4da7e1363424f5f632e02d975302f Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 13:26:42 -0400 Subject: [PATCH 07/10] Fix maindisplay macOS window flags test for changes --- tests/functional/openlp_core_ui/test_maindisplay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 86aaf5ea7..6b4d085a3 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -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): From db334bfa11fdd850e2a9fd667aa366db862b1b5f Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 13:30:19 -0400 Subject: [PATCH 08/10] Update systemplayer update_ui test for changes --- tests/functional/openlp_core_ui_media/test_systemplayer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_ui_media/test_systemplayer.py b/tests/functional/openlp_core_ui_media/test_systemplayer.py index e62133a0c..f499f10c9 100644 --- a/tests/functional/openlp_core_ui_media/test_systemplayer.py +++ b/tests/functional/openlp_core_ui_media/test_systemplayer.py @@ -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) From 49a074b95e8927c125839d4b0064309482ad868a Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Mon, 29 May 2017 13:31:56 -0400 Subject: [PATCH 09/10] Fix systemplayer get_info test --- tests/functional/openlp_core_ui_media/test_systemplayer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_ui_media/test_systemplayer.py b/tests/functional/openlp_core_ui_media/test_systemplayer.py index f499f10c9..396ae910e 100644 --- a/tests/functional/openlp_core_ui_media/test_systemplayer.py +++ b/tests/functional/openlp_core_ui_media/test_systemplayer.py @@ -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 From c10813218382c1d139082bd27ac573879abec9f5 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 27 Aug 2017 11:33:11 -0400 Subject: [PATCH 10/10] Remove extra space --- openlp/core/ui/media/mediacontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 2e56263c3..b778c68dd 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -435,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,"visible");') + display.frame.evaluateJavaScript('show_video("setBackBoard", null, null,"visible");') # now start playing - Preview is autoplay! autoplay = False # Preview requested