本文整理汇总了Python中openlp.core.ui.media.vlcplayer.VlcPlayer类的典型用法代码示例。如果您正苦于以下问题:Python VlcPlayer类的具体用法?Python VlcPlayer怎么用?Python VlcPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VlcPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_osx_test
def setup_osx_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method when running on OS X
"""
# GIVEN: A bunch of mocked out stuff and a VlcPlayer object
mocked_is_macosx.return_value = True
mocked_is_win.return_value = False
mocked_settings = MagicMock()
mocked_settings.value.return_value = False
MockedSettings.return_value = mocked_settings
mocked_qframe = MagicMock()
mocked_qframe.winId.return_value = 2
MockedQtGui.QFrame.NoFrame = 1
MockedQtGui.QFrame.return_value = mocked_qframe
mocked_media_player_new = MagicMock()
mocked_instance = MagicMock()
mocked_instance.media_player_new.return_value = mocked_media_player_new
mocked_vlc = MagicMock()
mocked_vlc.Instance.return_value = mocked_instance
mocked_get_vlc.return_value = mocked_vlc
mocked_display = MagicMock()
mocked_display.has_audio = False
mocked_display.controller.is_live = True
mocked_display.size.return_value = (10, 10)
vlc_player = VlcPlayer(None)
# WHEN: setup() is run
vlc_player.setup(mocked_display)
# THEN: set_nsobject should be called
mocked_media_player_new.set_nsobject.assert_called_with(2)
示例2: setup_visible_mouse_test
def setup_visible_mouse_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win):
"""
Test the setup method when Settings().value("hide mouse") is False
"""
# GIVEN: A bunch of mocked out stuff and a VlcPlayer object
mocked_is_macosx.return_value = False
mocked_is_win.return_value = False
mocked_settings = MagicMock()
mocked_settings.value.return_value = False
MockedSettings.return_value = mocked_settings
mocked_qframe = MagicMock()
mocked_qframe.winId.return_value = 2
MockedQtGui.QFrame.NoFrame = 1
MockedQtGui.QFrame.return_value = mocked_qframe
mocked_media_player_new = MagicMock()
mocked_instance = MagicMock()
mocked_instance.media_player_new.return_value = mocked_media_player_new
mocked_vlc = MagicMock()
mocked_vlc.Instance.return_value = mocked_instance
mocked_get_vlc.return_value = mocked_vlc
mocked_display = MagicMock()
mocked_display.has_audio = False
mocked_display.controller.is_live = True
mocked_display.size.return_value = (10, 10)
vlc_player = VlcPlayer(None)
# WHEN: setup() is run
vlc_player.setup(mocked_display)
# THEN: The VLC instance should be created with the correct options
mocked_vlc.Instance.assert_called_with('--no-video-title-show --no-audio --no-video-title-show')
示例3: play_test
def play_test(self, mocked_get_vlc, mocked_threading):
"""
Test the play() method
"""
# GIVEN: A bunch of mocked out things
mocked_thread = MagicMock()
mocked_threading.Thread.return_value = mocked_thread
mocked_vlc = MagicMock()
mocked_get_vlc.return_value = mocked_vlc
mocked_controller = MagicMock()
mocked_controller.media_info.start_time = 0
mocked_controller.media_info.media_type = MediaType.Video
mocked_controller.media_info.volume = 100
mocked_media = MagicMock()
mocked_media.get_duration.return_value = 50000
mocked_display = MagicMock()
mocked_display.controller = mocked_controller
mocked_display.vlc_media_player.get_media.return_value = mocked_media
vlc_player = VlcPlayer(None)
vlc_player.state = MediaState.Paused
# WHEN: play() is called
with patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait, \
patch.object(vlc_player, 'volume') as mocked_volume:
mocked_media_state_wait.return_value = True
result = vlc_player.play(mocked_display)
# THEN: A bunch of things should happen to play the media
mocked_thread.start.assert_called_with()
self.assertEqual(50, mocked_controller.media_info.length)
mocked_volume.assert_called_with(mocked_display, 100)
mocked_controller.seek_slider.setMaximum.assert_called_with(50000)
self.assertEqual(MediaState.Playing, vlc_player.state)
mocked_display.vlc_widget.raise_.assert_called_with()
self.assertTrue(result, 'The value returned from play() should be True')
示例4: update_ui_dvd_test
def update_ui_dvd_test(self, mocked_get_vlc):
"""
Test updating the UI for a CD or DVD
"""
# GIVEN: A whole bunch of mocks
mocked_vlc = MagicMock()
mocked_vlc.State.Ended = 1
mocked_get_vlc.return_value = mocked_vlc
mocked_controller = MagicMock()
mocked_controller.media_info.start_time = 100
mocked_controller.media_info.end_time = 300
mocked_controller.seek_slider.isSliderDown.return_value = False
mocked_display = MagicMock()
mocked_display.controller = mocked_controller
mocked_display.vlc_media.get_state.return_value = 1
mocked_display.vlc_media_player.get_time.return_value = 400000
mocked_display.controller.media_info.media_type = MediaType.DVD
vlc_player = VlcPlayer(None)
# WHEN: update_ui() is called
with patch.object(vlc_player, 'stop') as mocked_stop, \
patch.object(vlc_player, 'set_visible') as mocked_set_visible:
vlc_player.update_ui(mocked_display)
# THEN: Certain methods should be called
mocked_stop.assert_called_with(mocked_display)
self.assertEqual(2, mocked_stop.call_count)
mocked_display.vlc_media_player.get_time.assert_called_with()
mocked_set_visible.assert_called_with(mocked_display, False)
mocked_controller.seek_slider.setSliderPosition.assert_called_with(300000)
expected_calls = [call(True), call(False)]
self.assertEqual(expected_calls, mocked_controller.seek_slider.blockSignals.call_args_list)
示例5: load_test
def load_test(self, mocked_normcase, mocked_get_vlc):
"""
Test loading a video into VLC
"""
# GIVEN: A mocked out get_vlc() method
media_path = '/path/to/media.mp4'
mocked_normcase.side_effect = lambda x: x
mocked_vlc = MagicMock()
mocked_get_vlc.return_value = mocked_vlc
mocked_controller = MagicMock()
mocked_controller.media_info.volume = 100
mocked_controller.media_info.media_type = MediaType.Video
mocked_controller.media_info.file_info.absoluteFilePath.return_value = media_path
mocked_vlc_media = MagicMock()
mocked_media = MagicMock()
mocked_media.get_duration.return_value = 10000
mocked_display = MagicMock()
mocked_display.controller = mocked_controller
mocked_display.vlc_instance.media_new_path.return_value = mocked_vlc_media
mocked_display.vlc_media_player.get_media.return_value = mocked_media
vlc_player = VlcPlayer(None)
# WHEN: A video is loaded into VLC
with patch.object(vlc_player, 'volume') as mocked_volume:
result = vlc_player.load(mocked_display)
# THEN: The video should be loaded
mocked_normcase.assert_called_with(media_path)
mocked_display.vlc_instance.media_new_path.assert_called_with(media_path)
self.assertEqual(mocked_vlc_media, mocked_display.vlc_media)
mocked_display.vlc_media_player.set_media.assert_called_with(mocked_vlc_media)
mocked_vlc_media.parse.assert_called_with()
mocked_volume.assert_called_with(mocked_display, 100)
self.assertEqual(10, mocked_controller.media_info.length)
self.assertTrue(result)
示例6: play_media_wait_state_not_playing_test
def play_media_wait_state_not_playing_test(self, mocked_get_vlc, mocked_threading):
"""
Test the play() method when media_wait_state() returns False
"""
# GIVEN: A bunch of mocked out things
mocked_thread = MagicMock()
mocked_threading.Thread.return_value = mocked_thread
mocked_vlc = MagicMock()
mocked_get_vlc.return_value = mocked_vlc
mocked_controller = MagicMock()
mocked_controller.media_info.start_time = 0
mocked_display = MagicMock()
mocked_display.controller = mocked_controller
vlc_player = VlcPlayer(None)
vlc_player.state = MediaState.Paused
# WHEN: play() is called
with patch.object(vlc_player, 'media_state_wait') as mocked_media_state_wait, \
patch.object(vlc_player, 'volume') as mocked_volume:
mocked_media_state_wait.return_value = False
result = vlc_player.play(mocked_display)
# THEN: A thread should be started, but the method should return False
mocked_thread.start.assert_called_with()
self.assertFalse(result)
示例7: check_not_available_test
def check_not_available_test(self, mocked_get_vlc):
"""
Check that when the "vlc" module is not available, then VLC is set as unavailable
"""
# GIVEN: A mocked out get_vlc() method and a VlcPlayer instance
mocked_get_vlc.return_value = None
vlc_player = VlcPlayer(None)
# WHEN: vlc
is_available = vlc_player.check_available()
# THEN: VLC should NOT be available
self.assertFalse(is_available)
示例8: test_check_available
def test_check_available(self, mocked_get_vlc):
"""
Check that when the "vlc" module is available, then VLC is set as available
"""
# GIVEN: A mocked out get_vlc() method and a VlcPlayer instance
mocked_get_vlc.return_value = MagicMock()
vlc_player = VlcPlayer(None)
# WHEN: vlc
is_available = vlc_player.check_available()
# THEN: VLC should be available
self.assertTrue(is_available)
示例9: set_visible_has_own_widget_test
def set_visible_has_own_widget_test(self):
"""
Test the set_visible() method when the player has its own widget
"""
# GIVEN: Some mocked out stuff
mocked_display = MagicMock()
vlc_player = VlcPlayer(None)
vlc_player.has_own_widget = True
# WHEN: reset() is called
vlc_player.set_visible(mocked_display, True)
# THEN: The media should be stopped and invsibile
mocked_display.vlc_widget.setVisible.assert_called_with(True)
示例10: volume_no_audio_test
def volume_no_audio_test(self):
"""
Test setting the volume when there's no audio
"""
# GIVEN: A display object and a VlcPlayer instance
mocked_display = MagicMock()
mocked_display.has_audio = False
vlc_player = VlcPlayer(None)
# WHEN: The volume is set
vlc_player.volume(mocked_display, 10)
# THEN: The volume should NOT have been set
self.assertEqual(0, mocked_display.vlc_media_player.audio_set_volume.call_count)
示例11: set_visible_no_widget_test
def set_visible_no_widget_test(self):
"""
Test the set_visible() method when the player doesn't have a widget
"""
# GIVEN: Some mocked out stuff
mocked_display = MagicMock()
vlc_player = VlcPlayer(None)
vlc_player.has_own_widget = False
# WHEN: reset() is called
vlc_player.set_visible(mocked_display, True)
# THEN: The media should be stopped and invsibile
self.assertEqual(0, mocked_display.vlc_widget.setVisible.call_count)
示例12: volume_test
def volume_test(self):
"""
Test setting the volume
"""
# GIVEN: A display object and a VlcPlayer instance
mocked_display = MagicMock()
mocked_display.has_audio = True
vlc_player = VlcPlayer(None)
# WHEN: The volume is set
vlc_player.volume(mocked_display, 10)
# THEN: The volume should have been set
mocked_display.vlc_media_player.audio_set_volume.assert_called_with(10)
示例13: resize_test
def resize_test(self):
"""
Test resizing the player
"""
# GIVEN: A display object and a VlcPlayer instance
mocked_display = MagicMock()
mocked_display.size.return_value = (10, 10)
vlc_player = VlcPlayer(None)
# WHEN: resize is called
vlc_player.resize(mocked_display)
# THEN: The right methods should have been called
mocked_display.size.assert_called_with()
mocked_display.vlc_widget.resize.assert_called_with((10, 10))
示例14: get_info_test
def get_info_test(self, mocked_translate):
"""
Test that get_info() returns some information about the VLC player
"""
# GIVEN: A VlcPlayer
mocked_translate.side_effect = lambda *x: x[1]
vlc_player = VlcPlayer(None)
# WHEN: get_info() is run
info = vlc_player.get_info()
# THEN: The information should be correct
self.assertEqual('VLC is an external player which supports a number of different formats.<br/> '
'<strong>Audio</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>Video</strong><br/>' +
str(VIDEO_EXT) + '<br/>', info)
示例15: reset_test
def reset_test(self):
"""
Test the reset() method
"""
# GIVEN: Some mocked out stuff
mocked_display = MagicMock()
vlc_player = VlcPlayer(None)
# WHEN: reset() is called
vlc_player.reset(mocked_display)
# THEN: The media should be stopped and invsibile
mocked_display.vlc_media_player.stop.assert_called_with()
mocked_display.vlc_widget.setVisible.assert_called_with(False)
self.assertEqual(MediaState.Off, vlc_player.state)