diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index f974d949b..312afcd21 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -210,6 +210,8 @@ class Settings(QtCore.QSettings): 'media/media auto start': QtCore.Qt.Unchecked, 'media/stream command': '', 'media/vlc arguments': '', + 'media/video': '', + 'media/audio': '', 'remotes/download version': '0.0', 'players/background color': '#000000', 'servicemanager/last directory': None, diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 08e223054..588bf636e 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -184,7 +184,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): display.has_audio = False self.vlc_player.setup(display, preview) - def set_controls_visible(self, controller, value): + @staticmethod + def set_controls_visible(controller, value): """ After a new display is configured, all media related widget will be created too @@ -276,6 +277,8 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): # display.frame.runJavaScript('show_video("setBackBoard", null, null,"visible");') # now start playing - Preview is autoplay! autoplay = False + if service_item.is_capable(ItemCapabilities.CanStream): + autoplay = True # Preview requested if not controller.is_live: autoplay = True diff --git a/openlp/core/ui/media/mediatab.py b/openlp/core/ui/media/mediatab.py index 1f3ea2c4a..251d2e3e9 100644 --- a/openlp/core/ui/media/mediatab.py +++ b/openlp/core/ui/media/mediatab.py @@ -88,9 +88,6 @@ class MediaTab(SettingsTab): self.left_layout.addWidget(self.vlc_arguments_group_box) self.left_layout.addStretch() self.right_layout.addStretch() - self.video_edit.editingFinished.connect(self.on_field_changed) - self.audio_edit.editingFinished.connect(self.on_field_changed) - # # Signals and slots def retranslate_ui(self): """ @@ -107,10 +104,13 @@ class MediaTab(SettingsTab): """ self.auto_start_check_box.setChecked(Settings().value(self.settings_section + '/media auto start')) self.stream_cmd.setText(Settings().value(self.settings_section + '/stream command')) + self.audio_edit.setText(Settings().value(self.settings_section + '/audio')) + self.video_edit.setText(Settings().value(self.settings_section + '/video')) if not self.stream_cmd.text(): self.set_base_stream() self.vlc_arguments_edit.setPlainText(Settings().value(self.settings_section + '/vlc arguments')) if Settings().value('advanced/experimental'): + # vlc.MediaPlayer().audio_output_device_enum() for cam in QCameraInfo.availableCameras(): log.debug(cam.deviceName()) log.debug(cam.description()) @@ -134,9 +134,8 @@ class MediaTab(SettingsTab): Settings().setValue(setting_key, self.auto_start_check_box.checkState()) Settings().setValue(self.settings_section + '/stream command', self.stream_cmd.text()) Settings().setValue(self.settings_section + '/vlc arguments', self.vlc_arguments_edit.toPlainText()) - - def on_field_changed(self): - self.set_base_stream() + Settings().setValue(self.settings_section + '/video', self.video_edit.text()) + Settings().setValue(self.settings_section + '/audio', self.audio_edit.text()) self.stream_cmd.setText(self.stream_cmd.text().format(video=self.video_edit.text(), audio=self.audio_edit.text())) diff --git a/tests/functional/openlp_core/ui/media/test_mediacontroller.py b/tests/functional/openlp_core/ui/media/test_mediacontroller.py index b0e41c19c..3c8eb17f1 100644 --- a/tests/functional/openlp_core/ui/media/test_mediacontroller.py +++ b/tests/functional/openlp_core/ui/media/test_mediacontroller.py @@ -27,6 +27,7 @@ from unittest.mock import MagicMock, patch from openlp.core.common.registry import Registry from openlp.core.ui.media.mediacontroller import MediaController +from openlp.core.ui.media import ItemMediaInfo from tests.helpers.testmixin import TestMixin from tests.utils.constants import RESOURCE_PATH @@ -57,7 +58,7 @@ class TestMediaController(TestCase, TestMixin): # THEN: The player's resize method should be called correctly mocked_player.resize.assert_called_with(mocked_display) - def test_check_file_type(self): + def test_check_file_type_null(self): """ Test that we don't try to play media when no players available """ @@ -71,7 +72,47 @@ class TestMediaController(TestCase, TestMixin): ret = media_controller._check_file_type(mocked_controller, mocked_display) # THEN: it should return False - assert ret is False, '_check_file_type should return False when no mediaplayers are available.' + assert ret is False, '_check_file_type should return False when no media file matches.' + + def test_check_file_video(self): + """ + Test that we process a file that is valid + """ + # GIVEN: A mocked UiStrings, get_used_players, controller, display and service_item + media_controller = MediaController() + mocked_controller = MagicMock() + mocked_display = MagicMock() + media_controller.media_players = MagicMock() + mocked_controller.media_info = ItemMediaInfo() + mocked_controller.media_info.file_info = [TEST_PATH / 'mp3_file.mp3'] + media_controller.current_media_players = {} + media_controller.vlc_player = MagicMock() + + # WHEN: calling _check_file_type when no players exists + ret = media_controller._check_file_type(mocked_controller, mocked_display) + + # THEN: it should return False + assert ret is True, '_check_file_type should return True when audio file is present and matches.' + + def test_check_file_audio(self): + """ + Test that we process a file that is valid + """ + # GIVEN: A mocked UiStrings, get_used_players, controller, display and service_item + media_controller = MediaController() + mocked_controller = MagicMock() + mocked_display = MagicMock() + media_controller.media_players = MagicMock() + mocked_controller.media_info = ItemMediaInfo() + mocked_controller.media_info.file_info = [TEST_PATH / 'mp4_file.mp4'] + media_controller.current_media_players = {} + media_controller.vlc_player = MagicMock() + + # WHEN: calling _check_file_type when no players exists + ret = media_controller._check_file_type(mocked_controller, mocked_display) + + # THEN: it should return False + assert ret is True, '_check_file_type should return True when media file is present and matches.' def test_media_play_msg(self): """