mpv can't be run with UTF-8 filepath in Windows, so load UTF-8 files via API instead
This commit is contained in:
parent
fd6d15790a
commit
a4b35431fa
@ -3,9 +3,9 @@ import re
|
||||
import threading
|
||||
import time
|
||||
from syncplay.players.basePlayer import BasePlayer
|
||||
from syncplay import constants
|
||||
from syncplay import constants, utils
|
||||
from syncplay.messages import getMessage
|
||||
import os
|
||||
import os, sys
|
||||
|
||||
class MplayerPlayer(BasePlayer):
|
||||
speedSupported = True
|
||||
@ -29,6 +29,7 @@ class MplayerPlayer(BasePlayer):
|
||||
self.quitReason = None
|
||||
self.lastLoadedTime = None
|
||||
self.fileLoaded = False
|
||||
self.delayedFilePath = None
|
||||
try:
|
||||
self._listener = self.__Listener(self, playerPath, filePath, args)
|
||||
except ValueError:
|
||||
@ -264,7 +265,11 @@ class MplayerPlayer(BasePlayer):
|
||||
|
||||
call = [playerPath]
|
||||
if filePath:
|
||||
call.extend([filePath])
|
||||
if sys.platform.startswith('win') and not utils.isASCII(filePath):
|
||||
self.__playerController.delayedFilePath = filePath
|
||||
filePath = None
|
||||
else:
|
||||
call.extend([filePath])
|
||||
call.extend(playerController.getStartupArgs(playerPath))
|
||||
if args:
|
||||
call.extend(args)
|
||||
|
||||
@ -137,6 +137,8 @@ class NewMpvPlayer(OldMpvPlayer):
|
||||
self._client.updatePlayerStatus(self._paused, self._position)
|
||||
|
||||
def _preparePlayer(self):
|
||||
if self.delayedFilePath:
|
||||
self.openFile(self.delayedFilePath)
|
||||
self.setPaused(True)
|
||||
self.reactor.callLater(0, self._client.initPlayer, self)
|
||||
|
||||
|
||||
@ -121,11 +121,8 @@ class VlcPlayer(BasePlayer):
|
||||
fileURL = fileURL.replace("+", "%20")
|
||||
return fileURL
|
||||
|
||||
def _isASCII (self, s):
|
||||
return all(ord(c) < 128 for c in s)
|
||||
|
||||
def openFile(self, filePath, resetPosition=False):
|
||||
if self._isASCII(filePath):
|
||||
if utils.isASCII(filePath):
|
||||
self._listener.sendLine('load-file: {}'.format(filePath.encode('ascii', 'ignore')))
|
||||
else:
|
||||
fileURL = self.getMRL(filePath)
|
||||
@ -250,7 +247,7 @@ class VlcPlayer(BasePlayer):
|
||||
self.__playerController = playerController
|
||||
call = [playerPath]
|
||||
if filePath:
|
||||
if self.__playerController._isASCII(filePath):
|
||||
if utils.isASCII(filePath):
|
||||
call.append(filePath)
|
||||
else:
|
||||
call.append(self.__playerController.getMRL(filePath))
|
||||
|
||||
@ -108,6 +108,9 @@ def formatSize (bytes, precise=False):
|
||||
except: # E.g. when filesize is hashed
|
||||
return "???"
|
||||
|
||||
def isASCII(s):
|
||||
return all(ord(c) < 128 for c in s)
|
||||
|
||||
def findWorkingDir():
|
||||
frozen = getattr(sys, 'frozen', '')
|
||||
if not frozen:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user