Skip to content

Commit e01f190

Browse files
authored
Merge pull request #127 from Samillion/dev_chpt_seek_options
feat: add speed control option to seekbar mouse wheel action
2 parents 9a9d1c1 + 39249c5 commit e01f190

File tree

3 files changed

+73
-44
lines changed

3 files changed

+73
-44
lines changed

docs/USER_OPTS.md

+24-21
Original file line numberDiff line numberDiff line change
@@ -145,27 +145,30 @@ Create `modernz.conf` in your mpv script-opts directory:
145145

146146
### Mouse Commands (User Options)
147147

148-
Customize the button function based on mouse action same as you would in `input.conf`. [[details](https://mpv.io/manual/master/#list-of-input-commands)]
149-
150-
| Type | Option | Function |
151-
| -------------------- | ------------------------------ | --------------------------------------------------------------------------------|
152-
| Title (seekbar) | title_mbtn_left_command | `show-text ${media-title}` |
153-
| | title_mbtn_right_command | `show-text ${filename}` |
154-
| Playlist Button | playlist_mbtn_left_command | `script-binding select/select-playlist; script-message-to modernz osc-hide` |
155-
| | playlist_mbtn_right_command | `show-text ${playlist} 3000` |
156-
| Volume Control | volumectrl_mbtn_right_command | `script-binding select/select-audio-device; script-message-to modernz osc-hide` |
157-
| Audio Button | audio_track_mbtn_left_command | `script-binding select/select-aid; script-message-to modernz osc-hide` |
158-
| | audio_track_mbtn_right_command | `cycle audio` |
159-
| | audio_track_wheel_down_command | `cycle audio` |
160-
| | audio_track_wheel_up_command | `cycle audio down` |
161-
| Subtitle Button | sub_track_mbtn_left_command | `script-binding select/select-sid; script-message-to modernz osc-hide` |
162-
| | sub_track_mbtn_right_command | `cycle sub` |
163-
| | sub_track_wheel_down_command | `cycle sub` |
164-
| | sub_track_wheel_up_command | `cycle sub down` |
165-
| Chapter Skip Buttons | ch_prev_mbtn_left_command | `no-osd add chapter -1` |
166-
| | ch_prev_mbtn_right_command | `script-binding select/select-chapter; script-message-to modernz osc-hide` |
167-
| | ch_next_mbtn_left_command | `no-osd add chapter 1` |
168-
| | ch_next_mbtn_right_command | `script-binding select/select-chapter; script-message-to modernz osc-hide` |
148+
Customize the button function based on mouse actions.
149+
150+
| Type | Option | Function |
151+
| ----------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------- |
152+
| Seekbar Mode (mouse wheel) | seekbar_track_wheel_mode | default: `seek`<br> accepts `seek` or `speed`.<br>`speed` changes playback speed up/down |
153+
| Title (above seekbar) | title_mbtn_left_command | `show-text ${media-title}` |
154+
| | title_mbtn_right_command | `show-text ${filename}` |
155+
| Playlist Button | playlist_mbtn_left_command | `script-binding select/select-playlist; script-message-to modernz osc-hide` |
156+
| | playlist_mbtn_right_command | `show-text ${playlist} 3000` |
157+
| Volume Control | vol_ctrl_mbtn_right_command | `script-binding select/select-audio-device; script-message-to modernz osc-hide` |
158+
| Audio Button | audio_track_mbtn_left_command | `script-binding select/select-aid; script-message-to modernz osc-hide` |
159+
| | audio_track_mbtn_right_command | `cycle audio` |
160+
| | audio_track_wheel_down_command | `cycle audio` |
161+
| | audio_track_wheel_up_command | `cycle audio down` |
162+
| Subtitle Button | sub_track_mbtn_left_command | `script-binding select/select-sid; script-message-to modernz osc-hide` |
163+
| | sub_track_mbtn_right_command | `cycle sub` |
164+
| | sub_track_wheel_down_command | `cycle sub` |
165+
| | sub_track_wheel_up_command | `cycle sub down` |
166+
| Chapter Skip Buttons | chapter_prev_mbtn_left_command | `no-osd add chapter -1` |
167+
| | chapter_prev_mbtn_right_command | `script-binding select/select-chapter; script-message-to modernz osc-hide` |
168+
| | chapter_next_mbtn_left_command | `no-osd add chapter 1` |
169+
| | chapter_next_mbtn_right_command | `script-binding select/select-chapter; script-message-to modernz osc-hide` |
170+
| Chapter Title (below seekbar) | chapter_title_mbtn_left_command | `script-binding select/select-chapter; script-message-to modernz osc-hide` |
171+
| | chapter_title_mbtn_right_command | `show-text ${chapter-list} 3000` |
169172

170173
### Auto Profile
171174

modernz.conf

+13-6
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ tick_delay_follow_display_fps=no
184184
## Mouse commands
185185
## details: https://github.com/Samillion/ModernZ#mouse-commands-user-options
186186

187+
# seekbar mouse wheel mode. accepts: speed or seek. option speed adjusts playback speed.
188+
seekbar_track_wheel_mode=seek
189+
187190
# title above seekbar mouse actions
188191
title_mbtn_left_command=show-text ${media-title}
189192
title_mbtn_right_command=show-text ${filename}
@@ -192,8 +195,8 @@ title_mbtn_right_command=show-text ${filename}
192195
playlist_mbtn_left_command=script-binding select/select-playlist; script-message-to modernz osc-hide
193196
playlist_mbtn_right_command=show-text ${playlist} 3000
194197

195-
# volume control icon mouse actions
196-
volumectrl_mbtn_right_command=script-binding select/select-audio-device; script-message-to modernz osc-hide
198+
# volume mouse actions
199+
vol_ctrl_mbtn_right_command=script-binding select/select-audio-device; script-message-to modernz osc-hide
197200

198201
# audio button mouse actions
199202
audio_track_mbtn_left_command=script-binding select/select-aid; script-message-to modernz osc-hide
@@ -208,8 +211,12 @@ sub_track_wheel_down_command=cycle sub
208211
sub_track_wheel_up_command=cycle sub down
209212

210213
# chapter skip buttons mouse actions
211-
ch_prev_mbtn_left_command=no-osd add chapter -1
212-
ch_prev_mbtn_right_command=script-binding select/select-chapter; script-message-to modernz osc-hide
214+
chapter_prev_mbtn_left_command=no-osd add chapter -1
215+
chapter_prev_mbtn_right_command=script-binding select/select-chapter; script-message-to modernz osc-hide
216+
217+
chapter_next_mbtn_left_command=no-osd add chapter 1
218+
chapter_next_mbtn_right_command=script-binding select/select-chapter; script-message-to modernz osc-hide
213219

214-
ch_next_mbtn_left_command=no-osd add chapter 1
215-
ch_next_mbtn_right_command=script-binding select/select-chapter; script-message-to modernz osc-hide
220+
# chapter title (below seekbar) mouse actions
221+
chapter_title_mbtn_left_command=script-binding select/select-chapter; script-message-to modernz osc-hide
222+
chapter_title_mbtn_right_command=show-text ${chapter-list} 3000

modernz.lua

+36-17
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ local user_opts = {
134134

135135
-- Mouse commands
136136
-- customize the button function based on mouse action
137-
-- same as you would in input.conf
138-
-- details: https://mpv.io/manual/master/#list-of-input-commands
137+
138+
-- seekbar mouse wheel mode. accepts: "speed" or "seek". speed adjusts playback speed.
139+
seekbar_track_wheel_mode = "seek",
139140

140141
-- title above seekbar mouse actions
141142
title_mbtn_left_command = "show-text ${media-title}",
@@ -145,8 +146,8 @@ local user_opts = {
145146
playlist_mbtn_left_command = "script-binding select/select-playlist; script-message-to modernz osc-hide",
146147
playlist_mbtn_right_command = "show-text ${playlist} 3000",
147148

148-
-- volume control icon mouse actions
149-
volumectrl_mbtn_right_command = "script-binding select/select-audio-device; script-message-to modernz osc-hide",
149+
-- volume mouse actions
150+
vol_ctrl_mbtn_right_command = "script-binding select/select-audio-device; script-message-to modernz osc-hide",
150151

151152
-- audio button mouse actions
152153
audio_track_mbtn_left_command = "script-binding select/select-aid; script-message-to modernz osc-hide",
@@ -161,11 +162,15 @@ local user_opts = {
161162
sub_track_wheel_up_command = "osd-msg cycle sub down",
162163

163164
-- chapter skip buttons mouse actions
164-
ch_prev_mbtn_left_command = "osd-msg add chapter -1",
165-
ch_prev_mbtn_right_command = "script-binding select/select-chapter; script-message-to modernz osc-hide",
165+
chapter_prev_mbtn_left_command = "osd-msg add chapter -1",
166+
chapter_prev_mbtn_right_command = "script-binding select/select-chapter; script-message-to modernz osc-hide",
167+
168+
chapter_next_mbtn_left_command = "osd-msg add chapter 1",
169+
chapter_next_mbtn_right_command = "script-binding select/select-chapter; script-message-to modernz osc-hide",
166170

167-
ch_next_mbtn_left_command = "osd-msg add chapter 1",
168-
ch_next_mbtn_right_command = "script-binding select/select-chapter; script-message-to modernz osc-hide",
171+
-- chapter title (below seekbar) mouse actions
172+
chapter_title_mbtn_left_command = "script-binding select/select-chapter; script-message-to modernz osc-hide",
173+
chapter_title_mbtn_right_command = "show-text ${chapter-list} 3000",
169174
}
170175

171176
local osc_param = { -- calculated by osc_init()
@@ -1854,8 +1859,8 @@ local function osc_init()
18541859
ne.softrepeat = user_opts.chapter_softrepeat == true
18551860
ne.content = icons.rewind
18561861
ne.enabled = (have_ch) -- disables button when no chapters available.
1857-
ne.eventresponder["mbtn_left_down"] = command_callback(user_opts.ch_prev_mbtn_left_command)
1858-
ne.eventresponder["mbtn_right_down"] = command_callback(user_opts.ch_prev_mbtn_right_command)
1862+
ne.eventresponder["mbtn_left_down"] = command_callback(user_opts.chapter_prev_mbtn_left_command)
1863+
ne.eventresponder["mbtn_right_down"] = command_callback(user_opts.chapter_prev_mbtn_right_command)
18591864
ne.eventresponder["shift+mbtn_left_down"] = function () mp.commandv("seek", -60, jumpmode) end
18601865
ne.eventresponder["shift+mbtn_right_down"] = function () mp.command("show-text ${chapter-list} 3000") end
18611866

@@ -1865,8 +1870,8 @@ local function osc_init()
18651870
ne.softrepeat = user_opts.chapter_softrepeat == true
18661871
ne.content = icons.forward
18671872
ne.enabled = (have_ch) -- disables button when no chapters available.
1868-
ne.eventresponder["mbtn_left_down"] = command_callback(user_opts.ch_next_mbtn_left_command)
1869-
ne.eventresponder["mbtn_right_down"] = command_callback(user_opts.ch_next_mbtn_right_command)
1873+
ne.eventresponder["mbtn_left_down"] = command_callback(user_opts.chapter_next_mbtn_left_command)
1874+
ne.eventresponder["mbtn_right_down"] = command_callback(user_opts.chapter_next_mbtn_right_command)
18701875
ne.eventresponder["shift+mbtn_left_down"] = function () mp.commandv("seek", 60, jumpmode) end
18711876
ne.eventresponder["shift+mbtn_right_down"] = function () mp.command("show-text ${chapter-list} 3000") end
18721877

@@ -1939,7 +1944,7 @@ local function osc_init()
19391944
end
19401945
end
19411946
ne.eventresponder["mbtn_left_up"] = function () mp.commandv("cycle", "mute") end
1942-
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.volumectrl_mbtn_right_command)
1947+
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.vol_ctrl_mbtn_right_command)
19431948
ne.eventresponder["wheel_up_press"] = function ()
19441949
if state.mute then mp.commandv("cycle", "mute") end
19451950
mp.commandv("add", "volume", 5)
@@ -2206,8 +2211,22 @@ local function osc_init()
22062211
state.playingWhilstSeeking = false
22072212
end
22082213
end
2209-
ne.eventresponder["wheel_up_press"] = function () mp.commandv("seek", 10) end
2210-
ne.eventresponder["wheel_down_press"] = function () mp.commandv("seek", -10) end
2214+
ne.eventresponder["wheel_up_press"] = function ()
2215+
if user_opts.seekbar_track_wheel_mode == "speed" then
2216+
local current_speed = mp.get_property_number("speed")
2217+
mp.commandv("osd-msg", "set", "speed", math.min(100, current_speed + 0.1))
2218+
else
2219+
mp.commandv("seek", 10)
2220+
end
2221+
end
2222+
ne.eventresponder["wheel_down_press"] = function ()
2223+
if user_opts.seekbar_track_wheel_mode == "speed" then
2224+
local current_speed = mp.get_property_number("speed")
2225+
mp.commandv("osd-msg", "set", "speed", math.max(0.1, current_speed - 0.1))
2226+
else
2227+
mp.commandv("seek", -10)
2228+
end
2229+
end
22112230

22122231
--persistent seekbar
22132232
ne = new_element("persistentseekbar", "slider")
@@ -2303,8 +2322,8 @@ local function osc_init()
23032322
end
23042323
return "" -- fallback
23052324
end
2306-
ne.eventresponder["mbtn_left_down"] = function() mp.command("script-binding select/select-chapter; script-message-to modernz osc-hide") end
2307-
ne.eventresponder["mbtn_right_down"] = function() mp.command("show-text ${chapter-list} 3000") end
2325+
ne.eventresponder["mbtn_left_down"] = command_callback(user_opts.chapter_title_mbtn_left_command)
2326+
ne.eventresponder["mbtn_right_down"] = command_callback(user_opts.chapter_title_mbtn_right_command)
23082327

23092328
-- Total/remaining time display
23102329
ne = new_element("tc_right", "button")

0 commit comments

Comments
 (0)