コード例 #1
0
ファイル: vlc.py プロジェクト: xNinjaKittyx/syncplay
        def __init__(self, playerController, playerPath, filePath, args,
                     vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))

            def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
                vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if utils.meetsMinVersion(
                                        interface_version,
                                        constants.VLC_INTERFACE_MIN_VERSION):
                                    return True
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    return False
                playerController._client.ui.showErrorMessage(
                    getMessage("vlc-interface-not-installed"))
                return False

            if isLinux():
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'),
                    "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            if _usevlcintf(playerController.vlcIntfPath,
                           playerController.vlcIntfUserPath):
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{port=\"{}\"}}'.format(
                        str(playerController.vlcport)))
            else:
                if isLinux():
                    playerController.vlcDataPath = "/usr/lib/syncplay/resources"
                else:
                    playerController.vlcDataPath = utils.findWorkingDir(
                    ) + "\\resources"
                playerController.SLAVE_ARGS.append('--data-path={}'.format(
                    playerController.vlcDataPath))
                playerController.SLAVE_ARGS.append(
                    '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.
                    format(playerController.vlcModulePath,
                           str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if self.oldIntfVersion:
                self.__playerController.drop(
                    getMessage("vlc-interface-version-mismatch").format(
                        self.oldIntfVersion,
                        constants.VLC_INTERFACE_MIN_VERSION))

            else:
                if isWindows() and getattr(sys, 'frozen', '') and getattr(
                        sys, '_MEIPASS', ''
                ) is not None:  # Needed for pyinstaller --onefile bundle
                    self.__process = subprocess.Popen(call,
                                                      stdin=subprocess.PIPE,
                                                      stderr=subprocess.PIPE,
                                                      stdout=subprocess.PIPE,
                                                      shell=False,
                                                      creationflags=0x08000000)
                else:
                    self.__process = subprocess.Popen(call,
                                                      stderr=subprocess.PIPE,
                                                      stdout=subprocess.PIPE)
                self.timeVLCLaunched = time.time()
                if self._shouldListenForSTDOUT():
                    for line in iter(self.__process.stderr.readline, ''):
                        line = line.decode('utf-8')
                        self.vlcHasResponded = True
                        self.timeVLCLaunched = None
                        if "[syncplay]" in line:
                            if "Listening on host" in line:
                                break
                            if "Hosting Syncplay" in line:
                                break
                            elif "Couldn't find lua interface" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("vlc-failed-noscript").format(
                                        line), True)
                                break
                            elif "lua interface error" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("media-player-error").format(
                                        line), True)
                                break
                if not isMacOS():
                    self.__process.stderr = None
                else:
                    vlcoutputthread = threading.Thread(
                        target=self.handle_vlcoutput, args=())
                    vlcoutputthread.setDaemon(True)
                    vlcoutputthread.start()
                threading.Thread.__init__(self, name="VLC Listener")
                asynchat.async_chat.__init__(self)
                self.set_terminator(b'\n')
                self._ibuffer = []
                self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
                self._sendingData = threading.Lock()
コード例 #2
0
ファイル: vlc.py プロジェクト: wiiaboo/syncplay
        def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            def _usevlcintf(vlcIntfPath, vlcIntfUserPath):
                vlcSyncplayInterfacePath = vlcIntfPath + "syncplay.lua"
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    vlcSyncplayInterfacePath = vlcIntfUserPath + "syncplay.lua"
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if utils.meetsMinVersion(interface_version, constants.VLC_INTERFACE_MIN_VERSION):
                                    return True
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    return False
                playerController._client.ui.showErrorMessage(getMessage("vlc-interface-not-installed"))
                return False
            if isLinux():
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            if _usevlcintf(playerController.vlcIntfPath, playerController.vlcIntfUserPath):
                playerController.SLAVE_ARGS.append('--lua-config=syncplay={{port=\"{}\"}}'.format(str(playerController.vlcport)))
            else:
                if isLinux():
                    playerController.vlcDataPath = "/usr/lib/syncplay/resources"
                else:
                    playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
                playerController.SLAVE_ARGS.append('--data-path={}'.format(playerController.vlcDataPath))
                playerController.SLAVE_ARGS.append('--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(playerController.vlcModulePath, str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if self.oldIntfVersion:
                self.__playerController.drop(getMessage("vlc-interface-version-mismatch").format(self.oldIntfVersion,constants.VLC_INTERFACE_MIN_VERSION))

            else:
                self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
                self.timeVLCLaunched = time.time()
                if self._shouldListenForSTDOUT():
                    for line in iter(self.__process.stderr.readline, ''):
                        self.vlcHasResponded = True
                        self.timeVLCLaunched = None
                        if "[syncplay]" in line:
                            if "Listening on host" in line:
                                break
                            if "Hosting Syncplay" in line:
                                break
                            elif "Couldn't find lua interface" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("vlc-failed-noscript").format(line), True)
                                break
                            elif "lua interface error" in line:
                                playerController._client.ui.showErrorMessage(
                                    getMessage("media-player-error").format(line), True)
                                break
                if not isMacOS():
                    self.__process.stderr = None
                else:
                    vlcoutputthread = threading.Thread(target = self.handle_vlcoutput, args=())
                    vlcoutputthread.setDaemon(True)
                    vlcoutputthread.start()
                threading.Thread.__init__(self, name="VLC Listener")
                asynchat.async_chat.__init__(self)
                self.set_terminator("\n")
                self._ibuffer = []
                self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
                self._sendingData = threading.Lock()
コード例 #3
0
ファイル: vlc.py プロジェクト: squeaksies/syncplay
        def __init__(self, playerController, playerPath, filePath, args,
                     vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                if 'snap' in playerPath:
                    playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/'
                    playerController.vlcIntfUserPath = os.path.join(
                        os.getenv('HOME', '.'),
                        "snap/vlc/current/.local/share/vlc/lua/intf/")
                else:
                    playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                    playerController.vlcIntfUserPath = os.path.join(
                        os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'),
                    "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif "vlcportable.exe" in playerPath.lower():
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/App/vlc/lua/intf/"
                playerController.vlcIntfUserPath = playerController.vlcIntfPath
            else:
                playerController.vlcIntfPath = os.path.dirname(
                    playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"

            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage(
                    "Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage(
                        "Found syncplay.lua intf directory:'{}'".format(
                            vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage(
                        "syncplay.lua intf directory not found, so creating directory '{}'"
                        .format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755,
                                                        parents=True,
                                                        exist_ok=True)

            def _intfNeedsUpdating(vlcSyncplayInterfacePath):
                self.__playerController._client.ui.showDebugMessage(
                    "Checking if '{}' exists and if it is the expected version"
                    .format(vlcSyncplayInterfacePath))
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    self.__playerController._client.ui.showDebugMessage(
                        "syncplay.lua not found, so file needs copying")
                    return True
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if interface_version == constants.VLC_INTERFACE_VERSION:
                                    self.__playerController._client.ui.showDebugMessage(
                                        "syncplay.lua exists and is expected version, so no file needs copying"
                                    )
                                    return False
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    self.__playerController._client.ui.showDebugMessage(
                                        "syncplay.lua is {} but expected version is {} so file needs to be copied"
                                        .format(
                                            interface_version,
                                            constants.VLC_INTERFACE_VERSION))
                                    return True
                self.__playerController._client.ui.showDebugMessage(
                    "Up-to-dateness checks failed, so copy the file.")
                return True

            if _intfNeedsUpdating(
                    os.path.join(playerController.vlcIntfUserPath,
                                 "syncplay.lua")):
                try:
                    _createIntfFolder(playerController.vlcIntfUserPath)
                    copyForm = utils.findResourcePath("syncplay.lua")
                    copyTo = os.path.join(playerController.vlcIntfUserPath,
                                          "syncplay.lua")
                    self.__playerController._client.ui.showDebugMessage(
                        "Copying VLC Lua Interface from '{}' to '{}'".format(
                            copyForm, copyTo))
                    import shutil
                    if os.path.exists(copyTo):
                        os.chmod(copyTo, 0o755)
                    shutil.copyfile(copyForm, copyTo)
                    os.chmod(copyTo, 0o755)
                except Exception as e:
                    playerController._client.ui.showErrorMessage(e)
                    return
            if isLinux():
                playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                playerController.vlcDataPath = utils.findWorkingDir(
                ) + "\\resources"
            playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.
                format(playerController.vlcModulePath,
                       str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(
                    sys, '_MEIPASS',
                    '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(call,
                                                  stdin=subprocess.PIPE,
                                                  stderr=subprocess.PIPE,
                                                  stdout=subprocess.PIPE,
                                                  shell=False,
                                                  creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call,
                                                  stderr=subprocess.PIPE,
                                                  stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line),
                                True)
                            break
                        elif "lua interface error" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line),
                                True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(
                    target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator(b'\n')
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()
コード例 #4
0
        def __init__(self, playerController, playerPath, filePath, args, reactor):
            self.__playerController = playerController
            self.reactor = reactor
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None

            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                if 'snap' in playerPath:
                    self.__playerController.vlcIntfPath = '/snap/vlc/current/usr/lib/vlc/lua/intf/'
                    self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), "snap/vlc/current/.local/share/vlc/lua/intf/")
                else:
                    self.__playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                    self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                self.__playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                self.__playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif "vlcportable.exe" in playerPath.lower():
                self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/App/vlc/lua/intf/"
                self.__playerController.vlcIntfUserPath = playerController.vlcIntfPath
            else:
                self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            self.__playerController.vlcModulePath = self.__playerController.vlcIntfPath + "modules/?.luac"
            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage("Found syncplay.lua intf directory:'{}'".format(vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua intf directory not found, so creating directory '{}'".format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755, parents=True, exist_ok=True)
            try:
                _createIntfFolder(self.__playerController.vlcIntfUserPath)
                copyForm = utils.findResourcePath("syncplay.lua")
                copyTo = os.path.join(self.__playerController.vlcIntfUserPath, "syncplay.lua")
                self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo))
                import shutil
                if os.path.exists(copyTo):
                    os.chmod(copyTo, 0o755)
                shutil.copyfile(copyForm, copyTo)
                os.chmod(copyTo, 0o755)
            except Exception as e:
                self.__playerController._client.ui.showErrorMessage(e)
                return
            if isLinux():
                self.__playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                self.__playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
            self.__playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(
                    self.__playerController.vlcModulePath, str(self.__playerController.vlcport)))

            call.extend(self.__playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(
                    call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
                    shell=False, creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            self.__playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line), True)
                            break
                        elif "lua interface error" in line:
                            self.__playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line), True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            self.__playerController._vlcready.clear()
            self._factory = VLCClientFactory(self.__playerController, self.vlcHasResponded, self.timeVLCLaunched, self.__process)
            self.reactor.connectTCP('localhost', self.__playerController.vlcport, self._factory)
コード例 #5
0
ファイル: vlc.py プロジェクト: Syncplay/syncplay
        def __init__(self, playerController, playerPath, filePath, args, vlcReady, vlcClosed):
            self.__playerController = playerController
            self.requestedVLCVersion = False
            self.vlcHasResponded = False
            self.oldIntfVersion = None
            self.timeVLCLaunched = None
            call = [playerPath]
            if filePath:
                if utils.isASCII(filePath):
                    call.append(filePath)
                else:
                    call.append(self.__playerController.getMRL(filePath))
            if isLinux():
                playerController.vlcIntfPath = "/usr/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            elif isMacOS():
                playerController.vlcIntfPath = "/Applications/VLC.app/Contents/MacOS/share/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(
                    os.getenv('HOME', '.'), "Library/Application Support/org.videolan.vlc/lua/intf/")
            elif isBSD():
                # *BSD ports/pkgs install to /usr/local by default.
                # This should also work for all the other BSDs, such as OpenBSD or DragonFly.
                playerController.vlcIntfPath = "/usr/local/lib/vlc/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('HOME', '.'), ".local/share/vlc/lua/intf/")
            else:
                playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/"
                playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\")
            playerController.vlcModulePath = playerController.vlcIntfPath + "modules/?.luac"
            def _createIntfFolder(vlcSyncplayInterfaceDir):
                self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists")
                from pathlib import Path
                if os.path.exists(vlcSyncplayInterfaceDir):
                    self.__playerController._client.ui.showDebugMessage("Found syncplay.lua intf directory:'{}'".format(vlcSyncplayInterfaceDir))
                else:
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua intf directory not found, so creating directory '{}'".format(vlcSyncplayInterfaceDir))
                    Path(vlcSyncplayInterfaceDir).mkdir(mode=0o755, parents=True, exist_ok=True)
            def _intfNeedsUpdating(vlcSyncplayInterfacePath):
                self.__playerController._client.ui.showDebugMessage("Checking if '{}' exists and if it is the expected version".format(vlcSyncplayInterfacePath))
                if not os.path.isfile(vlcSyncplayInterfacePath):
                    self.__playerController._client.ui.showDebugMessage("syncplay.lua not found, so file needs copying")
                    return True
                if os.path.isfile(vlcSyncplayInterfacePath):
                    with open(vlcSyncplayInterfacePath, 'rU') as interfacefile:
                        for line in interfacefile:
                            if "local connectorversion" in line:
                                interface_version = line[26:31]
                                if interface_version == constants.VLC_INTERFACE_VERSION:
                                    self.__playerController._client.ui.showDebugMessage("syncplay.lua exists and is expected version, so no file needs copying")
                                    return False
                                else:
                                    self.oldIntfVersion = line[26:31]
                                    self.__playerController._client.ui.showDebugMessage("syncplay.lua is {} but expected version is {} so file needs to be copied".format(interface_version, constants.VLC_INTERFACE_VERSION))
                                    return True
                self.__playerController._client.ui.showDebugMessage("Up-to-dateness checks failed, so copy the file.")
                return True
            if _intfNeedsUpdating(os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")):
                try:
                    _createIntfFolder(playerController.vlcIntfUserPath)
                    copyForm = utils.findResourcePath("syncplay.lua")
                    copyTo = os.path.join(playerController.vlcIntfUserPath, "syncplay.lua")
                    self.__playerController._client.ui.showDebugMessage("Copying VLC Lua Interface from '{}' to '{}'".format(copyForm, copyTo))
                    import shutil
                    if os.path.exists(copyTo):
                        os.chmod(copyTo, 0o755)
                    shutil.copyfile(copyForm, copyTo)
                    os.chmod(copyTo, 0o755)
                except Exception as e:
                    playerController._client.ui.showErrorMessage(e)
                    return
            if isLinux():
                playerController.vlcDataPath = "/usr/lib/syncplay/resources"
            else:
                playerController.vlcDataPath = utils.findWorkingDir() + "\\resources"
            playerController.SLAVE_ARGS.append('--data-path={}'.format(playerController.vlcDataPath))
            playerController.SLAVE_ARGS.append(
                '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format(
                    playerController.vlcModulePath, str(playerController.vlcport)))

            call.extend(playerController.SLAVE_ARGS)
            if args:
                call.extend(args)

            self._vlcready = vlcReady
            self._vlcclosed = vlcClosed
            self._vlcVersion = None

            if isWindows() and getattr(sys, 'frozen', '') and getattr(sys, '_MEIPASS', '') is not None:  # Needed for pyinstaller --onefile bundle
                self.__process = subprocess.Popen(
                    call, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
                    shell=False, creationflags=0x08000000)
            else:
                self.__process = subprocess.Popen(call, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            self.timeVLCLaunched = time.time()
            if self._shouldListenForSTDOUT():
                for line in iter(self.__process.stderr.readline, ''):
                    line = line.decode('utf-8')
                    self.vlcHasResponded = True
                    self.timeVLCLaunched = None
                    if "[syncplay]" in line:
                        if "Listening on host" in line:
                            break
                        if "Hosting Syncplay" in line:
                            break
                        elif "Couldn't find lua interface" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("vlc-failed-noscript").format(line), True)
                            break
                        elif "lua interface error" in line:
                            playerController._client.ui.showErrorMessage(
                                getMessage("media-player-error").format(line), True)
                            break
            if not isMacOS():
                self.__process.stderr = None
            else:
                vlcoutputthread = threading.Thread(target=self.handle_vlcoutput, args=())
                vlcoutputthread.setDaemon(True)
                vlcoutputthread.start()
            threading.Thread.__init__(self, name="VLC Listener")
            asynchat.async_chat.__init__(self)
            self.set_terminator(b'\n')
            self._ibuffer = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self._sendingData = threading.Lock()