Update vlc.py

This commit is contained in:
ixlammm 2023-06-09 20:32:57 +01:00
parent 7de5e23b0e
commit 936999a1e2

View File

@ -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)