From 7cc367801a568855c1c7e5fa04d43463c93cbeb3 Mon Sep 17 00:00:00 2001 From: Daniel Martin Date: Wed, 28 Apr 2021 06:19:47 +0000 Subject: [PATCH] More media fixes --- openlp/core/ui/media/mediacontroller.py | 7 ++--- openlp/core/ui/media/mediaplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- .../ui/media/test_mediacontroller.py | 27 +++++++++++++++++++ .../openlp_core/ui/media/test_vlcplayer.py | 6 ++--- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b185e5bef..b33bf5901 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -328,6 +328,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'), translate('MediaPlugin.MediaItem', 'Unsupported File')) return False + self._update_seek_ui(controller) self.set_controls_visible(controller, True) self.log_debug('use {nm} controller'. format(nm=self.current_media_players[controller.controller_type].display_name)) @@ -493,7 +494,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): stopped = True if start_again: - controller.seek_slider.setSliderPosition(0) + controller.media_info.timer = 0 + self._update_seek_ui(controller) return not stopped def _update_seek_ui(self, controller): @@ -530,7 +532,6 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): if controller.controller_type in self.current_media_players: self.current_media_players[controller.controller_type].pause(controller) controller.mediabar.actions['playbackPlay'].setVisible(True) - controller.mediabar.actions['playbackStop'].setDisabled(False) controller.mediabar.actions['playbackPause'].setVisible(False) controller.media_info.is_playing = False # Add a tick to the timer to prevent it finishing the video before it can loop back or stop @@ -586,7 +587,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): if not controller.media_info.is_background: display = self._define_display(controller) if display.hide_mode == HideMode.Screen: - controller.set_hide_mode(HideMode.Blank) + Registry().execute('live_display_hide', HideMode.Blank) else: controller.set_hide_mode(display.hide_mode or HideMode.Blank) else: diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index b70373f39..bceac4dbd 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -76,7 +76,7 @@ class MediaPlayer(RegistryProperties): def play(self, controller, display): """ - Starts playing of current Media File + Starts playing of current Media File, media player is expected to loop automatically :param controller: Which Controller is running the show. :param display: The display to be updated. diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 3c5b75f99..2fbb6ace5 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -113,7 +113,7 @@ class VlcPlayer(MediaPlayer): controller.vlc_widget = QtWidgets.QFrame(display) controller.vlc_widget.setFrameStyle(QtWidgets.QFrame.NoFrame) # creating a basic vlc instance - command_line_options = '--no-video-title-show ' + command_line_options = '--no-video-title-show --input-repeat=99999999 ' if self.settings.value('advanced/hide mouse') and controller.is_live: command_line_options += '--mouse-hide-timeout=0 ' if self.settings.value('media/vlc arguments'): diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index 8bd5cf7f9..ff2787aea 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -218,6 +218,33 @@ def test_media_stop(media_env): mocked_slide_controller.set_hide_mode.assert_called_once_with(HideMode.Blank) +def test_media_stop_no_hide_change(media_env): + """ + Test that the media_stop doesn't change the hide mode of OpenLP when screen is visible + """ + # GIVEN: A live media controller and a message with two elements + mocked_slide_controller = MagicMock() + mocked_media_player = MagicMock() + mocked_display = MagicMock(hide_mode=HideMode.Screen) + mocked_slide_controller.controller_type = 'media player' + mocked_slide_controller.media_info = MagicMock(is_background=False) + mocked_slide_controller.set_hide_mode = MagicMock() + mocked_slide_controller.is_live = True + media_env.media_controller.current_media_players = {'media player': mocked_media_player} + media_env.media_controller.live_hide_timer = MagicMock() + media_env.media_controller._define_display = MagicMock(return_value=mocked_display) + + # WHEN: media_stop() is called + result = media_env.media_controller.media_stop(mocked_slide_controller) + + # THEN: Result should be successful, media player should be stopped and the hide timer should have started + # The controller's hide mode should not have been set + assert result is True + mocked_media_player.stop.assert_called_once_with(mocked_slide_controller) + media_env.media_controller.live_hide_timer.start.assert_called_once() + mocked_slide_controller.set_hide_mode.assert_not_called() + + def test_media_volume_msg(media_env): """ Test that the media controller responds to the request to change the volume diff --git a/tests/functional/openlp_core/ui/media/test_vlcplayer.py b/tests/functional/openlp_core/ui/media/test_vlcplayer.py index ec7cd8f37..958be6ac8 100644 --- a/tests/functional/openlp_core/ui/media/test_vlcplayer.py +++ b/tests/functional/openlp_core/ui/media/test_vlcplayer.py @@ -116,7 +116,7 @@ def test_setup(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win, mocked_qframe.setFrameStyle.assert_called_with(1) mock_settings.value.assert_any_call('advanced/hide mouse') mock_settings.value.assert_any_call('media/vlc arguments') - mocked_vlc.Instance.assert_called_with('--no-video-title-show ') + mocked_vlc.Instance.assert_called_with('--no-video-title-show --input-repeat=99999999 ') assert mocked_output_display.vlc_instance == mocked_instance mocked_instance.media_player_new.assert_called_with() assert mocked_output_display.vlc_media_player == mocked_media_player_new @@ -159,7 +159,7 @@ def test_setup_has_audio(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mock vlc_player.setup(mocked_output_display, mocked_controller) # THEN: The VLC instance should be created with the correct options - mocked_vlc.Instance.assert_called_with('--no-video-title-show ') + mocked_vlc.Instance.assert_called_with('--no-video-title-show --input-repeat=99999999 ') @patch('openlp.core.ui.media.vlcplayer.is_win') @@ -194,7 +194,7 @@ def test_setup_visible_mouse(MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, vlc_player.setup(mocked_output_display, mocked_controller) # THEN: The VLC instance should be created with the correct options - mocked_vlc.Instance.assert_called_with('--no-video-title-show ') + mocked_vlc.Instance.assert_called_with('--no-video-title-show --input-repeat=99999999 ') @patch('openlp.core.ui.media.vlcplayer.is_win')