← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~springermac/openlp/media-fixes into lp:openlp

 

Jonathan Springer has proposed merging lp:~springermac/openlp/media-fixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~springermac/openlp/media-fixes/+merge/329664

- 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
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~springermac/openlp/media-fixes into lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2017-08-01 20:59:41 +0000
+++ openlp/core/ui/maindisplay.py	2017-08-26 14:02:15 +0000
@@ -157,7 +157,7 @@
         # 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)

=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py	2017-08-23 20:13:58 +0000
+++ openlp/core/ui/media/mediacontroller.py	2017-08-26 14:02:15 +0000
@@ -297,7 +297,9 @@
                                                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 @@
         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 @@
             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 @@
             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 @@
         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 @@
         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 @@
         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():

=== modified file 'openlp/core/ui/media/systemplayer.py'
--- openlp/core/ui/media/systemplayer.py	2016-12-31 11:01:36 +0000
+++ openlp/core/ui/media/systemplayer.py	2017-08-26 14:02:15 +0000
@@ -258,7 +258,7 @@
         :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:

=== modified file 'tests/functional/openlp_core_ui/test_maindisplay.py'
--- tests/functional/openlp_core_ui/test_maindisplay.py	2017-06-05 18:22:14 +0000
+++ tests/functional/openlp_core_ui/test_maindisplay.py	2017-08-26 14:02:15 +0000
@@ -154,9 +154,9 @@
         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):

=== modified file 'tests/functional/openlp_core_ui_media/test_systemplayer.py'
--- tests/functional/openlp_core_ui_media/test_systemplayer.py	2017-04-24 05:17:55 +0000
+++ tests/functional/openlp_core_ui_media/test_systemplayer.py	2017-08-26 14:02:15 +0000
@@ -402,7 +402,7 @@
         """
         # 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 @@
             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 @@
         # 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


Follow ups