From 936999a1e2e3967804b70d10266af5c89b533572 Mon Sep 17 00:00:00 2001 From: ixlammm Date: Fri, 9 Jun 2023 20:32:57 +0100 Subject: [PATCH] Update vlc.py --- syncplay/players/vlc.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/syncplay/players/vlc.py b/syncplay/players/vlc.py index b60bb62..d52fcc8 100755 --- a/syncplay/players/vlc.py +++ b/syncplay/players/vlc.py @@ -10,6 +10,7 @@ import time import urllib.error import urllib.parse import urllib.request +import ctypes from twisted.internet.protocol import ReconnectingClientFactory from twisted.protocols.basic import LineReceiver @@ -297,6 +298,8 @@ class VlcPlayer(BasePlayer): # value = value.decode('utf-8') self._filepath = value self._pathAsk.set() + elif name == "chat": + self._listener.sendChat(value) elif name == "duration" or name == "duration-change": if value == "no-input": self._duration = 0 @@ -455,6 +458,21 @@ class VlcPlayer(BasePlayer): else: self.__playerController.vlcIntfPath = os.path.dirname(playerPath).replace("\\", "/") + "/lua/intf/" self.__playerController.vlcIntfUserPath = os.path.join(os.getenv('APPDATA', '.'), "VLC\\lua\\intf\\") + + copyTo = os.path.join(os.path.dirname(playerPath) + "\\plugins\\control\\", "libsyncplay_chat_plugin.dll") + if not os.path.exists(copyTo): + copyForm = utils.findResourcePath("libsyncplay_chat_plugin.dll") + self.__playerController._client.ui.showDebugMessage("Copying VLC Syncplay Chat Plugin from '{}' to '{}'".format(copyForm, copyTo)) + import ctypes + commands = u'/k mklink /H "{}" "{}"'.format(copyTo, copyForm) + ctypes.windll.shell32.ShellExecuteW( + None, + u"runas", + u"cmd.exe", + commands, + None, + 0 + ) self.__playerController.vlcModulePath = self.__playerController.vlcIntfPath + "modules/?.luac" def _createIntfFolder(vlcSyncplayInterfaceDir): self.__playerController._client.ui.showDebugMessage("Checking if syncplay.lua intf directory exists") @@ -484,6 +502,8 @@ class VlcPlayer(BasePlayer): self.__playerController.SLAVE_ARGS.append( '--lua-config=syncplay={{modulepath=\"{}\",port=\"{}\"}}'.format( self.__playerController.vlcModulePath, str(self.__playerController.vlcport))) + self.__playerController.SLAVE_ARGS.append( + '--reset-plugins-cache') call.extend(self.__playerController.SLAVE_ARGS) if args: @@ -540,3 +560,5 @@ class VlcPlayer(BasePlayer): def sendLine(self, line): self.reactor.callFromThread(self._factory.protocol.sendLine, line) + def sendChat(self, message): + self.reactor.callFromThread(self.__playerController._client.sendChat, message)