forked from openlp/openlp
Added check to see if given path exists.
This commit is contained in:
parent
4b83741b36
commit
73304d7ec3
@ -122,11 +122,18 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
|
|||||||
"""
|
"""
|
||||||
self.disable_all()
|
self.disable_all()
|
||||||
path = self.media_path_combobox.currentText()
|
path = self.media_path_combobox.currentText()
|
||||||
|
# Check if given path is non-empty and exists before starting VLC
|
||||||
if path == '':
|
if path == '':
|
||||||
log.debug('no given path')
|
log.debug('no given path')
|
||||||
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm', 'No path was given'))
|
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm', 'No path was given'))
|
||||||
self.toggle_disable_load_media(False)
|
self.toggle_disable_load_media(False)
|
||||||
return
|
return
|
||||||
|
if not os.path.exists(path):
|
||||||
|
log.debug('vlc media player is none')
|
||||||
|
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
|
||||||
|
'Given path does not exists'))
|
||||||
|
self.toggle_disable_load_media(False)
|
||||||
|
return
|
||||||
self.vlc_media = self.vlc_instance.media_new_path(path)
|
self.vlc_media = self.vlc_instance.media_new_path(path)
|
||||||
if not self.vlc_media:
|
if not self.vlc_media:
|
||||||
log.debug('vlc media player is none')
|
log.debug('vlc media player is none')
|
||||||
@ -141,11 +148,13 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
|
|||||||
if self.vlc_media_player.play() < 0:
|
if self.vlc_media_player.play() < 0:
|
||||||
log.debug('vlc play returned error')
|
log.debug('vlc play returned error')
|
||||||
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
|
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
|
||||||
'An error happen when starting VLC player'))
|
'VLC player failed playing the media'))
|
||||||
self.toggle_disable_load_media(False)
|
self.toggle_disable_load_media(False)
|
||||||
return
|
return
|
||||||
self.vlc_media_player.audio_set_mute(True)
|
self.vlc_media_player.audio_set_mute(True)
|
||||||
if not self.media_state_wait(vlc.State.Playing):
|
if not self.media_state_wait(vlc.State.Playing):
|
||||||
|
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
|
||||||
|
'VLC player failed playing the media'))
|
||||||
self.toggle_disable_load_media(False)
|
self.toggle_disable_load_media(False)
|
||||||
return
|
return
|
||||||
self.vlc_media_player.pause()
|
self.vlc_media_player.pause()
|
||||||
@ -453,4 +462,4 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
|
|||||||
continue
|
continue
|
||||||
dirs = os.listdir('/Volumes/' + volume)
|
dirs = os.listdir('/Volumes/' + volume)
|
||||||
if 'VIDEO_TS' in dirs:
|
if 'VIDEO_TS' in dirs:
|
||||||
self.media_path_combobox.addItem()
|
self.media_path_combobox.addItem('/Volumes/' + volume)
|
||||||
|
@ -56,10 +56,6 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
|
|||||||
self.vlc_patcher.start()
|
self.vlc_patcher.start()
|
||||||
# Mock the media item
|
# Mock the media item
|
||||||
self.mock_media_item = MagicMock()
|
self.mock_media_item = MagicMock()
|
||||||
# Mock media_state_wait to avoid waiting for VLC playing state
|
|
||||||
#self.mock_media_state_wait = patch('openlp.plugins.media.forms.mediaclipselectorform.media_state_wait')
|
|
||||||
#self.mock_media_state_wait.return_value = True
|
|
||||||
#self.mock_media_state_wait.start()
|
|
||||||
# create form to test
|
# create form to test
|
||||||
self.form = MediaClipSelectorForm(self.mock_media_item, self.main_window, None)
|
self.form = MediaClipSelectorForm(self.mock_media_item, self.main_window, None)
|
||||||
mock_media_state_wait = MagicMock()
|
mock_media_state_wait = MagicMock()
|
||||||
@ -70,7 +66,6 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Delete all the C++ objects at the end so that we don't have a segfault
|
Delete all the C++ objects at the end so that we don't have a segfault
|
||||||
"""
|
"""
|
||||||
#self.mock_media_state_wait.stop()
|
|
||||||
self.vlc_patcher.stop()
|
self.vlc_patcher.stop()
|
||||||
del self.form
|
del self.form
|
||||||
del self.main_window
|
del self.main_window
|
||||||
|
Loading…
Reference in New Issue
Block a user