-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure seek bar to use bottom bar OSD #124
Comments
What you're asking for is a known issue in mpv [1], [2]. I found an only slightly hacky workaround until this gets fixed upstream: #!/usr/bin/env python3
import sys
import mpv
def logger(loglevel, component, message):
print('[{}] {}: {}'.format(loglevel, component, message), file=sys.stderr)
def play(media):
print("play('{}')".format(media), file=sys.stderr)
player = mpv.MPV(ytdl=True,
log_handler=logger,
input_default_bindings=True,
input_vo_keyboard=True,
terminal=True,
input_terminal=True,
osd_bar=False,
scripts='test.lua'
)
player.on_key_press('ESC')(player.quit)
player.on_key_press('ENTER')(lambda: player.playlist_next(mode='force'))
try:
for item in media:
player.play(item)
player.wait_for_playback()
except mpv.ShutdownError:
pass
player.terminate()
if __name__ == '__main__':
play(media=['LGR Plays - Goat Simulator-j4HY_fxwiZo.mp4']) Put this lua script in the current working directory or somewhere else mpv can find it: -- emulate require() path search but load into current scope instead.
-- osc.lua does not export a module table, so require would just return True.
for key, loader in pairs(package.loaders) do
res = loader('@osc.lua')
print('res value', '"', res, '"', type(res))
if type(res) == 'function' then
print('found', res, res('@osc.lua'))
break
end
end
function seek_handler()
show_osc()
end
mp.register_event("seek", seek_handler) |
To expand on this: The thing on the bottom is the "on-screen controller" (osc) and is drawn from mpv's included "osc.lua" script. The bar in the middle is part of the "on-screen display" (osd) and is drawn from mpv's core C code. Both are functionally independent pieces of code. What the above code does is it loads the built-in "osc.lua" script and patches in another event listener that will show it on seeks, automatically hiding it like with mouse movements. |
Beautiful. That works perfect. |
@jaseg can you please tell somewhat more about how this scrpit should be used? I do not use Python MPV but I was searching for the solution of this annoying property of MPV and found this issue. Putting osc.lua into a folder as described by MPV manual was not enough. |
@pbaykalov I have saved that lua script as $ mpv --script=~/.config/mpv/scripts/osc_on_seek.lua /path/to/video/file |
@pbaykalov If you are using mpv from the command-line as opposed to as a library, saving it to your user scripts as @AndydeCleyre wrote is the way to go. edit: Just in case, "the script" here is not osc.lua, but the second code block above. That code block loads and modifies mpv's own osc.lua. @AndydeCleyre The reason I passed the script as an option in the code example is that when you use mpv as a library, you would not want to install this kind of script into a user's config. Instead, it would have to be kept as part of your program, and |
The Lua script you suggested seeems to always break the controls in pseudo-GUI in weird way: it stops accepting mouse clicks. |
I'm trying to make the LEFT/RIGHT seek bar use the nice new bottom bar OSD/OSC(?). This example has the bottom bar if it's moused-over, but hitting LEFT/RIGHT draws the seek bar in the middle of the video instead of using the bottombar. Using git-latest.
The text was updated successfully, but these errors were encountered: