mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-09 07:27:01 +00:00
* Advance playlist on end of file in mpv and VLC * Update duration for streams to fix playlist advancement (#334)
This commit is contained in:
parent
77ce05d02d
commit
c063369e3c
@ -500,6 +500,11 @@ class SyncplayClient(object):
|
||||
return True
|
||||
return self._globalPaused
|
||||
|
||||
def eofReportedByPlayer(self):
|
||||
if self.playlist.notJustChangedPlaylist() and self.userlist.currentUser.file:
|
||||
self.ui.showDebugMessage("Fixing file duration to allow for playlist advancement")
|
||||
self.userlist.currentUser.file["duration"] = self._playerPosition
|
||||
|
||||
def updateFile(self, filename, duration, path):
|
||||
self.lastUpdatedFileTime = time.time()
|
||||
newPath = ""
|
||||
|
@ -131,7 +131,7 @@ COMMANDS_DELETE = ['delete', 'd', 'qd']
|
||||
MPC_MIN_VER = "1.6.4"
|
||||
MPC_BE_MIN_VER = "1.5.2.3123"
|
||||
VLC_MIN_VERSION = "2.2.1"
|
||||
VLC_INTERFACE_VERSION = "0.3.6"
|
||||
VLC_INTERFACE_VERSION = "0.3.7"
|
||||
VLC_LATENCY_ERROR_THRESHOLD = 2.0
|
||||
MPV_UNRESPONSIVE_THRESHOLD = 60.0
|
||||
CONTROLLED_ROOMS_MIN_VERSION = "1.3.0"
|
||||
@ -289,7 +289,7 @@ VLC_SLAVE_EXTRA_ARGS = getValueForOS({
|
||||
MPV_SUPERSEDE_IF_DUPLICATE_COMMANDS = ["set_property time-pos ", "loadfile "]
|
||||
MPV_REMOVE_BOTH_IF_DUPLICATE_COMMANDS = ["cycle pause"]
|
||||
MPLAYER_ANSWER_REGEX = "^ANS_([a-zA-Z_-]+)=(.+)$|^(Exiting)\.\.\. \((.+)\)$"
|
||||
VLC_ANSWER_REGEX = r"(?:^(?P<command>[a-zA-Z_]+)(?:\: )?(?P<argument>.*))"
|
||||
VLC_ANSWER_REGEX = r"(?:^(?P<command>[a-zA-Z_-]+)(?:\: )?(?P<argument>.*))"
|
||||
UI_COMMAND_REGEX = r"^(?P<command>[^\ ]+)(?:\ (?P<parameter>.+))?"
|
||||
UI_OFFSET_REGEX = r"^(?:o|offset)\ ?(?P<sign>[/+-])?(?P<time>\d{1,9}(?:[^\d\.](?:\d{1,9})){0,2}(?:\.(?:\d{1,3}))?)$"
|
||||
UI_SEEK_REGEX = r"^(?:s|seek)?\ ?(?P<sign>[+-])?(?P<time>\d{1,4}(?:[^\d\.](?:\d{1,6})){0,2}(?:\.(?:\d{1,3}))?)$"
|
||||
|
@ -213,6 +213,9 @@ class MpvPlayer(BasePlayer):
|
||||
else:
|
||||
return self._position
|
||||
|
||||
def eofDetected(self):
|
||||
self._client.eofReportedByPlayer()
|
||||
|
||||
def _storePosition(self, value):
|
||||
if value is None:
|
||||
self._client.ui.showDebugMessage("NONE TYPE POSITION!")
|
||||
@ -420,11 +423,13 @@ class MpvPlayer(BasePlayer):
|
||||
|
||||
def _handleUnknownLine(self, line):
|
||||
self.mpvErrorCheck(line)
|
||||
|
||||
if "<chat>" in line:
|
||||
line = line.replace(constants.MPV_INPUT_BACKSLASH_SUBSTITUTE_CHARACTER, "\\")
|
||||
self._listener.sendChat(line[6:-7])
|
||||
|
||||
if "<eof>" in line:
|
||||
self.eofDetected()
|
||||
|
||||
if "<paused=" in line and ", pos=" in line:
|
||||
update_string = line.replace(">", "<").replace("=", "<").replace(", ", "<").split("<")
|
||||
paused_update = update_string[2]
|
||||
|
@ -297,7 +297,7 @@ class VlcPlayer(BasePlayer):
|
||||
# value = value.decode('utf-8')
|
||||
self._filepath = value
|
||||
self._pathAsk.set()
|
||||
elif name == "duration":
|
||||
elif name == "duration" or name == "duration-change":
|
||||
if value == "no-input":
|
||||
self._duration = 0
|
||||
elif value == "invalid-32-bit-value":
|
||||
@ -306,6 +306,11 @@ class VlcPlayer(BasePlayer):
|
||||
else:
|
||||
self._duration = float(value.replace(",", "."))
|
||||
self._durationAsk.set()
|
||||
if name == "duration-change":
|
||||
self._filechanged = True
|
||||
t = threading.Thread(target=self._onFileUpdate)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
elif name == "playstate":
|
||||
self._paused = bool(value != 'playing') if (value != "no-input" and self._filechanged == False) else self._client.getGlobalPaused()
|
||||
diff = time.time() - self._lastVLCPositionUpdate if self._lastVLCPositionUpdate else 0
|
||||
|
@ -5,7 +5,7 @@
|
||||
Principal author: Etoh
|
||||
Other contributors: DerGenaue, jb, Pilotat
|
||||
Project: https://syncplay.pl/
|
||||
Version: 0.3.6
|
||||
Version: 0.3.7
|
||||
|
||||
Note:
|
||||
* This interface module is intended to be used in conjunction with Syncplay.
|
||||
@ -78,7 +78,7 @@ Syncplay should install this automatically to your user folder.
|
||||
|
||||
--]==========================================================================]
|
||||
|
||||
local connectorversion = "0.3.6"
|
||||
local connectorversion = "0.3.7"
|
||||
local vlcversion = vlc.misc.version()
|
||||
local vlcmajorversion = tonumber(vlcversion:sub(1,1)) -- get the major version of VLC
|
||||
|
||||
@ -114,6 +114,8 @@ local newfilepath
|
||||
local newinputstate
|
||||
local oldtitle = 0
|
||||
local newtitle = 0
|
||||
local oldduration = 0
|
||||
local newduration = 0
|
||||
|
||||
local channel1
|
||||
local channel2
|
||||
@ -179,6 +181,11 @@ function detectchanges()
|
||||
oldtitle = newtitle
|
||||
notificationbuffer = notificationbuffer .. "playstate"..msgseperator..tostring(get_play_state())..msgterminator
|
||||
notificationbuffer = notificationbuffer .. "position"..msgseperator..tostring(get_time())..msgterminator
|
||||
newduration = get_duration()
|
||||
if oldduration ~= newduration then
|
||||
oldduration = newduration
|
||||
notificationbuffer = notificationbuffer .. "duration-change"..msgseperator..tostring(newduration)..msgterminator
|
||||
end
|
||||
else
|
||||
notificationbuffer = notificationbuffer .. "playstate"..msgseperator..noinput..msgterminator
|
||||
notificationbuffer = notificationbuffer .. "position"..msgseperator..noinput..msgterminator
|
||||
@ -189,7 +196,6 @@ function detectchanges()
|
||||
oldinputstate = newinputstate
|
||||
notificationbuffer = notificationbuffer.."inputstate-change"..msgseperator..tostring(newinputstate)..msgterminator
|
||||
end
|
||||
|
||||
return notificationbuffer
|
||||
end
|
||||
|
||||
@ -406,7 +412,7 @@ function get_duration ()
|
||||
local i = 0
|
||||
response = 0
|
||||
repeat
|
||||
vlc.misc.mwait(vlc.misc.mdate() + durationdelay)
|
||||
-- vlc.misc.mwait(vlc.misc.mdate() + durationdelay)
|
||||
if item and item:duration() then
|
||||
response = item:duration()
|
||||
if response < 1 then
|
||||
@ -420,7 +426,6 @@ function get_duration ()
|
||||
else
|
||||
errormsg = noinput
|
||||
end
|
||||
|
||||
return response, errormsg
|
||||
end
|
||||
|
||||
@ -490,7 +495,10 @@ function do_command ( command, argument)
|
||||
|
||||
if command == "get-interface-version" then response = "interface-version"..msgseperator..connectorversion..msgterminator
|
||||
elseif command == "get-vlc-version" then response = "vlc-version"..msgseperator..vlcversion..msgterminator
|
||||
elseif command == "get-duration" then response = "duration"..msgseperator..errormerge(get_duration())..msgterminator
|
||||
elseif command == "get-duration" then
|
||||
newduration = errormerge(get_duration())
|
||||
response = "duration"..msgseperator..newduration..msgterminator
|
||||
oldduration = newduration
|
||||
elseif command == "get-filepath" then response = "filepath"..msgseperator..errormerge(get_filepath())..msgterminator
|
||||
elseif command == "get-filename" then response = "filename"..msgseperator..errormerge(get_filename())..msgterminator
|
||||
elseif command == "get-title" then response = "title"..msgseperator..errormerge(get_var("title", 0))..msgterminator
|
||||
|
@ -295,6 +295,13 @@ end
|
||||
|
||||
chat_timer=mp.add_periodic_timer(TICK_INTERVAL, chat_update)
|
||||
|
||||
mp.observe_property('eof-reached', 'bool', function(e)
|
||||
if mp.get_property_native("eof-reached") == true then
|
||||
mp.command('print-text "<eof>"')
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
mp.register_script_message('chat', function(e)
|
||||
add_chat(e)
|
||||
end)
|
||||
@ -985,7 +992,7 @@ function readyMpvAfterSettingsKnown()
|
||||
add_repl_alpharow_bindings(alpharowbindings)
|
||||
mp.add_forced_key_binding('tab', handle_tab)
|
||||
end
|
||||
end
|
||||
end
|
||||
syncplayintfSet = true
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user