mirror of
https://github.com/Syncplay/syncplay
synced 2025-01-05 14:20:33 +00:00
VLC3 compatability
This commit is contained in:
parent
734efae775
commit
401e08a7e0
@ -5,7 +5,7 @@
|
||||
Principal author: Etoh
|
||||
Other contributors: DerGenaue, jb, Pilotat
|
||||
Project: http://syncplay.pl/
|
||||
Version: 0.3.2
|
||||
Version: 0.3.3
|
||||
|
||||
Note:
|
||||
* This interface module is intended to be used in conjunction with Syncplay.
|
||||
@ -84,7 +84,7 @@ You may also need to re-copy the syncplay.lua file when you update VLC.
|
||||
|
||||
--]==========================================================================]
|
||||
|
||||
local connectorversion = "0.3.2"
|
||||
local connectorversion = "0.3.3"
|
||||
local vlcversion = vlc.misc.version()
|
||||
local vlcmajorversion = tonumber(vlcversion:sub(1,1)) -- get the major version of VLC
|
||||
local durationdelay = 500000 -- Pause for get_duration command etc for increased reliability (uses microseconds)
|
||||
@ -122,15 +122,6 @@ local l
|
||||
|
||||
local running = true
|
||||
|
||||
if vlcmajorversion == 3 then
|
||||
-- VLC 3 does not currently support syncplay
|
||||
running = false
|
||||
vlc.msg.err("This version of VLC does not support Syncplay. Please use VLC 2.2.1+ or an alternative media player. VLC 3 does not support Syncplay.")
|
||||
while true do
|
||||
vlc.misc.quit()
|
||||
vlc.misc.mwait(vlc.misc.mdate()+100000)
|
||||
end
|
||||
end
|
||||
|
||||
function radixsafe_tonumber(str)
|
||||
-- Version of tonumber that works with any radix character (but not thousand seperators)
|
||||
@ -252,6 +243,10 @@ function get_var( vartoget, fallbackvar )
|
||||
errormsg = noinput
|
||||
end
|
||||
|
||||
if vlcmajorversion == 3 and vartoget == "time" then
|
||||
response = response / 1000000
|
||||
end
|
||||
|
||||
return response, errormsg
|
||||
end
|
||||
|
||||
@ -262,6 +257,10 @@ function set_var(vartoset, varvalue)
|
||||
local errormsg
|
||||
local input = vlc.object.input()
|
||||
|
||||
if vlcmajorversion == 3 and vartoset == "time" then
|
||||
varvalue = varvalue * 1000000
|
||||
end
|
||||
|
||||
if input then
|
||||
vlc.var.set(input,tostring(vartoset),varvalue)
|
||||
else
|
||||
@ -473,10 +472,7 @@ function load_file (filepath)
|
||||
-- [Used by load-file command]
|
||||
|
||||
local uri = vlc.strings.make_uri(filepath)
|
||||
vlc.playlist.clear()
|
||||
vlc.playlist.enqueue({{path=uri}})
|
||||
vlc.playlist.next()
|
||||
vlc.playlist.play()
|
||||
vlc.playlist.add({{path=uri}})
|
||||
return "load-file-attempted\n"
|
||||
end
|
||||
|
||||
@ -544,9 +540,9 @@ function set_playstate(argument)
|
||||
end
|
||||
|
||||
if string.sub(vlcversion,1,2) == "1." or string.sub(vlcversion,1,3) == "2.0" or string.sub(vlcversion,1,3) == "2.1" or string.sub(vlcversion,1,5) == "2.2.0" then
|
||||
vlc.msg.err("This version of VLC does not support Syncplay. Please use VLC 2.2.1+ or an alternative media player. VLC 3 does not support Syncplay.")
|
||||
vlc.msg.err("This version of VLC does not support Syncplay. Please use VLC 2.2.1+ or an alternative media player..")
|
||||
quit_vlc()
|
||||
elseif vlcmajorversion ~= 3 then
|
||||
else
|
||||
l = vlc.net.listen_tcp(host, port)
|
||||
vlc.msg.info("Hosting Syncplay interface on port: "..port)
|
||||
end
|
||||
|
@ -54,6 +54,7 @@ DO_NOT_RESET_POSITION_THRESHOLD = 1.0
|
||||
SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear on some media players
|
||||
PLAYLIST_MAX_CHARACTERS = 10000
|
||||
PLAYLIST_MAX_ITEMS = 250
|
||||
VLC_LISTEN_FOR_STDOUT = False # Changing to True this could break VLC 3 on Windows
|
||||
|
||||
# Options for the File Switch feature:
|
||||
FOLDER_SEARCH_FIRST_FILE_TIMEOUT = 15.0 # Secs - How long to wait to find the first file in folder search (to take account of HDD spin up)
|
||||
@ -75,7 +76,7 @@ COMMANDS_AUTH = ['a','auth']
|
||||
COMMANDS_TOGGLE = ['t','toggle']
|
||||
MPC_MIN_VER = "1.6.4"
|
||||
VLC_MIN_VERSION = "2.2.1"
|
||||
VLC_INTERFACE_MIN_VERSION = "0.3.2"
|
||||
VLC_INTERFACE_MIN_VERSION = "0.3.3"
|
||||
VLC_LATENCY_ERROR_THRESHOLD = 2.0
|
||||
MPV_UNRESPONSIVE_THRESHOLD = 60.0
|
||||
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"
|
||||
|
@ -92,7 +92,6 @@ en = {
|
||||
"language-changed-msgbox-label" : "Language will be changed when you run Syncplay.",
|
||||
"promptforupdate-label" : u"Is it okay for Syncplay to automatically check for updates from time to time?",
|
||||
|
||||
"vlc-version-mismatch": u"This version of VLC does not support Syncplay. VLC {}+ supports Syncplay but VLC 3 does not. Please use an alternative media player.", # VLC min version
|
||||
"vlc-interface-version-mismatch": "You are running version {} of the Syncplay interface module for VLC, but Syncplay is designed to run with version {} and above. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.", # VLC interface version, VLC interface min version
|
||||
"vlc-interface-oldversion-warning": "Warning: Syncplay detected that an old version version of the Syncplay interface module for VLC was installed in the VLC directory. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.",
|
||||
"vlc-interface-not-installed": "Warning: The Syncplay interface module for VLC was not found in the VLC directory. As such, if you are running VLC 2.0 then VLC will use the syncplay.lua module contained within the Syncplay directory, but this will mean that other custom interface scripts and extensions will not work. Please refer to the Syncplay User Guide at http://syncplay.pl/guide/ for instructions on how to install syncplay.lua.",
|
||||
@ -128,10 +127,9 @@ en = {
|
||||
"not-json-error" : "Not a json encoded string\n",
|
||||
"hello-arguments-error" : "Not enough Hello arguments\n",
|
||||
"version-mismatch-error" : "Mismatch between versions of client and server\n",
|
||||
"vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua then please refer to http://syncplay.pl/LUA/ for instructions.",
|
||||
"vlc-failed-connection": "Failed to connect to VLC. If you have not installed syncplay.lua and are using the latest verion of VLC then please refer to http://syncplay.pl/LUA/ for instructions.",
|
||||
"vlc-failed-noscript": "VLC has reported that the syncplay.lua interface script has not been installed. Please refer to http://syncplay.pl/LUA/ for instructions.",
|
||||
"vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay. Please use VLC 2.",
|
||||
"vlc-failed-other" : "When trying to load the syncplay.lua interface script VLC has provided the following error: {}", # Syncplay Error
|
||||
"vlc-failed-versioncheck": "This version of VLC is not supported by Syncplay.",
|
||||
|
||||
"not-supported-by-server-error" : "This feature is not supported by the server. The feature requires a server running Syncplay {}+, but the server is running Syncplay {}.", #minVersion, serverVersion
|
||||
"shared-playlists-not-supported-by-server-error" : "The shared playlists feature may not be supported by the server. To ensure that it works correctly requires a server running Syncplay {}+, but the server is running Syncplay {}.", #minVersion, serverVersion
|
||||
|
@ -199,7 +199,7 @@ class VlcPlayer(BasePlayer):
|
||||
and self._position == self._previousPreviousPosition \
|
||||
and self._previousPosition == self._position \
|
||||
and self._duration > constants.PLAYLIST_LOAD_NEXT_FILE_MINIMUM_LENGTH \
|
||||
and abs(self._position - self._duration) < constants.PLAYLIST_LOAD_NEXT_FILE_TIME_FROM_END_THRESHOLD:
|
||||
and self._position == self._duration:
|
||||
self._paused = True
|
||||
self._client.ui.showDebugMessage("Treating 'playing' response as 'paused' due to VLC EOF bug")
|
||||
self._pausedAsk.set()
|
||||
@ -207,6 +207,8 @@ class VlcPlayer(BasePlayer):
|
||||
self._previousPreviousPosition = self._previousPosition
|
||||
self._previousPosition = self._position
|
||||
self._position = float(value.replace(",", ".")) if (value != "no-input" and self._filechanged == False) else self._client.getGlobalPosition()
|
||||
if self._position < 0 and self._duration > 2147 and self._vlcVersion == "3.0.0":
|
||||
self._client.ui.showErrorMessage("VLC reported its playback position as {} seconds, which could indicate you are using an old version of VLC 3 that does not report the position correctly for files 35 minutes and longer. Please update to the latest version of VLC!".format(int(self._position)))
|
||||
self._lastVLCPositionUpdate = time.time()
|
||||
self._positionAsk.set()
|
||||
elif name == "filename":
|
||||
@ -214,8 +216,8 @@ class VlcPlayer(BasePlayer):
|
||||
self._filename = value.decode('utf-8')
|
||||
self._filenameAsk.set()
|
||||
elif line.startswith("vlc-version: "):
|
||||
vlc_version = line.split(': ')[1].replace(' ','-').split('-')[0]
|
||||
if not utils.meetsMinVersion(vlc_version, constants.VLC_MIN_VERSION):
|
||||
self._vlcVersion = line.split(': ')[1].replace(' ','-').split('-')[0]
|
||||
if not utils.meetsMinVersion(self._vlcVersion, constants.VLC_MIN_VERSION):
|
||||
self._client.ui.showErrorMessage(getMessage("vlc-version-mismatch").format(constants.VLC_MIN_VERSION))
|
||||
self._vlcready.set()
|
||||
|
||||
@ -337,25 +339,29 @@ class VlcPlayer(BasePlayer):
|
||||
|
||||
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)
|
||||
for line in iter(self.__process.stderr.readline, ''):
|
||||
self.vlcHasResponded = True
|
||||
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 constants.VLC_LISTEN_FOR_STDOUT:
|
||||
for line in iter(self.__process.stderr.readline, ''):
|
||||
self.vlcHasResponded = True
|
||||
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
|
||||
self.__process.stderr = None
|
||||
threading.Thread.__init__(self, name="VLC Listener")
|
||||
asynchat.async_chat.__init__(self)
|
||||
@ -385,9 +391,10 @@ class VlcPlayer(BasePlayer):
|
||||
if self.vlcHasResponded:
|
||||
self.__playerController.drop()
|
||||
else:
|
||||
self.__playerController.drop(getMessage("vlc-version-mismatch").format(constants.VLC_MIN_VERSION))
|
||||
self.__playerController.drop(getMessage("vlc-failed-connection").format(constants.VLC_MIN_VERSION))
|
||||
|
||||
def found_terminator(self):
|
||||
self.vlcHasResponded = True
|
||||
self.__playerController.lineReceived("".join(self._ibuffer))
|
||||
self._ibuffer = []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user