mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 21:57:12 -05:00
fix win32 audio issue when temp dir has foreign chars
This commit is contained in:
parent
e55d4768a3
commit
b8711fe853
1 changed files with 5 additions and 2 deletions
|
|
@ -62,7 +62,8 @@ if sys.platform == "win32":
|
||||||
# python2.7+
|
# python2.7+
|
||||||
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
|
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
|
||||||
# tmp dir for non-hashed media
|
# tmp dir for non-hashed media
|
||||||
tmpdir = tempfile.mkdtemp(prefix="anki")
|
tmpdir = unicode(
|
||||||
|
tempfile.mkdtemp(prefix="anki"), sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
si = None
|
si = None
|
||||||
|
|
||||||
|
|
@ -207,7 +208,8 @@ def queueMplayer(path):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
if tmpdir and os.path.exists(path):
|
if tmpdir and os.path.exists(path):
|
||||||
# mplayer on windows doesn't like the encoding, so we create a
|
# mplayer on windows doesn't like the encoding, so we create a
|
||||||
# temporary file instead
|
# temporary file instead. oddly, foreign characters in the dirname
|
||||||
|
# don't seem to matter.
|
||||||
(fd, name) = tempfile.mkstemp(suffix=os.path.splitext(path)[1],
|
(fd, name) = tempfile.mkstemp(suffix=os.path.splitext(path)[1],
|
||||||
dir=tmpdir)
|
dir=tmpdir)
|
||||||
f = os.fdopen(fd, "wb")
|
f = os.fdopen(fd, "wb")
|
||||||
|
|
@ -215,6 +217,7 @@ def queueMplayer(path):
|
||||||
f.close()
|
f.close()
|
||||||
# it wants unix paths, too!
|
# it wants unix paths, too!
|
||||||
path = name.replace("\\", "/")
|
path = name.replace("\\", "/")
|
||||||
|
path = path.encode(sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
path = path.encode("utf-8")
|
path = path.encode("utf-8")
|
||||||
mplayerQueue.append(path)
|
mplayerQueue.append(path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue