Fix disc loading for windows

This commit is contained in:
Tomas Groth 2014-07-03 11:27:54 +02:00
parent 6f7f3be3ff
commit d19e7bf3aa
2 changed files with 11 additions and 2 deletions

View File

@ -204,3 +204,5 @@ class Ui_MediaClipSelector(object):
self.subtitle_track_label.setText(translate("MediaPlugin.MediaClipSelector", "Subtitle track", None))
self.jump_end_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Jump to end point", None))
self.media_path_label.setText(translate("MediaPlugin.MediaClipSelector", "Media path", None))
self.media_path_combobox.lineEdit().setPlaceholderText(translate("MediaPlugin.MediaClipSelector",
"Select drive from list", None))

View File

@ -35,6 +35,7 @@ import sys
if sys.platform.startswith('linux'):
import dbus
import logging
import re
from datetime import datetime
@ -207,7 +208,13 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
'Given path does not exists'))
self.toggle_disable_load_media(False)
return
self.vlc_media = self.vlc_instance.media_new_location('file://' + path)
# If on windows fix path for VLC use
if os.name == 'nt':
# If the given path is in the format "D:\" or "D:", prefix it with "/" to make VLC happy
pattern = re.compile('^\w:\\\\*$')
if pattern.match(path):
path = '/' + path
self.vlc_media = self.vlc_instance.media_new_location('dvd://' + path)
if not self.vlc_media:
log.debug('vlc media player is none')
critical_error_message_box(message=translate('MediaPlugin.MediaClipSelectorForm',
@ -583,7 +590,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
if os.name == 'nt':
# use win api to find optical drives
fso = Dispatch('scripting.filesystemobject')
for drive in fso.Drives :
for drive in fso.Drives:
log.debug('Drive %s has type %d' % (drive.DriveLetter, drive.DriveType))
# if type is 4, it is a cd-rom drive
if drive.DriveType == 4: