Skip to content
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

Fix subtitle margin #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modern.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1628,9 +1628,21 @@ function osc_visible(visible)
if state.osc_visible ~= visible then
state.osc_visible = visible
end
subtitle_fix()
request_tick()
end

function subtitle_fix()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to adjust subtitle positioning based on the resolution of the window, else subtitles are obstructed.

function adjustSubtitles()
    if user_opts.raisesubswithosc and state.osc_visible == true and (state.fullscreen == false or user_opts.showfullscreen) then
        local w, h = mp.get_osd_size()
        if h > 0 then
            mp.commandv('set', 'sub-pos', math.floor((osc_param.playresy - 175)/osc_param.playresy*100)) -- percentage
        end
	else
		mp.commandv('set', 'sub-pos', 100)
	end	
end

This is my solution to this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't exactly understand your code, but I replaced the function you wrote with my own function, but it didn't work. Did I make a mistake somewhere?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I'm sorry! I may have changed the subroutine name in my code from subtitle_fix() to adjustSubtitles(), try that!

I didn't exactly understand your code, but I replaced the function you wrote with my own function, but it didn't work. Did I make a mistake somewhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this. I replaced the code inside the function you wrote with my own code and it didn't work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh im sorry ... it's the user_opts.raisesubswithosc ... remove that (and the and) and maybe it'll work? Sorry my own fork is slightly different in the implementation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh im sorry ... it's the user_opts.raisesubswithosc ... remove that (and the and) and maybe it'll work? Sorry my own fork is slightly different in the implementation.

No, that didn't work either.

if state.osc_visible == true and (state.fullscreen == false or user_opts.showfullscreen) then
local w, h = mp.get_osd_size()
if h > 0 then
mp.commandv('set', 'sub-pos', math.floor(100-(80/h*100)))
end
else
mp.commandv('set', 'sub-pos', 100)
end
end

function pause_state(name, enabled)
state.paused = enabled
if user_opts.showtitle then
Expand Down Expand Up @@ -1685,6 +1697,7 @@ end

-- Like request_init(), but also request an immediate update
function request_init_resize()
subtitle_fix() -- When OSC always show
request_init()
-- ensure immediate update
state.tick_timer:kill()
Expand Down