Last active
July 15, 2023 06:14
-
-
Save bitingsock/19c3094cc8680bb7b97b09aaf7d11176 to your computer and use it in GitHub Desktop.
stops the demuxer from downloading more if it is already past --end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local maxBytes = mp.get_property("demuxer-max-bytes") | |
local function stopCache() | |
local state = mp.get_property_native("demuxer-cache-state") | |
if state and state["cache-end"] and tonumber(state["cache-end"]) > tonumber(mp.get_property("end")) then | |
mp.set_property("demuxer-max-bytes",0) | |
print("stop") | |
mp.unobserve_property(stopCache) | |
end | |
end | |
local function look() | |
if mp.get_property("end") ~= "none" then | |
maxBytes = mp.get_property("demuxer-max-bytes") | |
mp.observe_property("time-pos", "number", stopCache) | |
end | |
end | |
look() | |
mp.add_key_binding("alt+c", "restore", function() mp.set_property("demuxer-max-bytes",maxBytes); print("continue"); end) | |
mp.add_key_binding("alt+x", "look", look) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This, of course, relies on the fact that mp.set_property("demuxer-max-bytes",0) doesn't just delete the cache which I would have thought it might. Hopefully this does not change.