aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <epedroni@pm.me>2025-02-22 07:50:53 +0100
committerEddy Pedroni <epedroni@pm.me>2025-02-22 07:50:53 +0100
commitb676f88b21ef8046dcd3d9dac4b270007f2b959a (patch)
treee1169c2815778a802a9213152e16b5ee94a798d5
parent2404f7b5507393bf2f8dcb60ba6886f3cda799aa (diff)
Add very dirty partial implementation of web UI
-rw-r--r--web-project/src/solo_tool_web.py81
1 files changed, 44 insertions, 37 deletions
diff --git a/web-project/src/solo_tool_web.py b/web-project/src/solo_tool_web.py
index 859dba2..f854e1a 100644
--- a/web-project/src/solo_tool_web.py
+++ b/web-project/src/solo_tool_web.py
@@ -1,48 +1,55 @@
from nicegui import ui
+from solo_tool import SoloTool
+
+st = SoloTool()
+st.loadSession("/home/eddy/music/solos/practice.json")
+
+def _createSeekHandler(delta):
+ def f():
+ newPosition = st.getPlaybackPosition() + delta
+ newPosition = min(1.0, max(0.0, newPosition))
+ st.setPlaybackPosition(newPosition)
+ return f
+
def main():
with ui.splitter(value=30) as splitter:
splitter.style('width: 100%; height: 100%;')
with splitter.before:
with ui.list().props('dense separator'):
- ui.item('Sweet Child o\' Mine')
- ui.item('Elembivos')
- ui.item('Tears of the Dragon')
- ui.item('Victory Song')
+ for song in st.getSongs():
+ ui.item(song)
with splitter.after:
- with ui.column() as column:
- column.style('width: 100%;')
-
- ui.slider(min=0, max=120, value=100)
-
- with ui.row():
- ui.button('-5')
- ui.slider(min=50, max=120, step=5, value=100)
- ui.button('+5')
-
- ui.slider(min=0, max=100, value=0)
-
- with ui.row():
- ui.button('Prev')
- ui.button('-25%')
- ui.button('-5%')
- ui.button('-1%')
- ui.button('+1%')
- ui.button('+5%')
- ui.button('+25%')
- ui.button('Next')
-
- with ui.row():
- ui.button('Set A')
- ui.button('Set B')
- ui.button('Previous AB')
- ui.button('Next AB')
-
- with ui.row():
- ui.button('Toggle AB')
- ui.button('Stop')
- ui.button('Start')
- ui.button('Jump to A')
+ ui.slider(min=0, max=1.2, value=1.0, step=0.01, on_change=lambda e: st.setPlaybackVolume(e.value))
+
+ with ui.row().classes("w-full justify-between no-wrap"):
+ ui.button('-5%', on_click=lambda: st.setPlaybackRate(max(0.5, st.getPlaybackRate() - 0.05)))
+ ui.slider(min=0.5, max=1.2, step=0.05, value=st.getPlaybackRate(), on_change=lambda e: st.setPlaybackRate(e.value))
+ ui.button('+5%', on_click=lambda: st.setPlaybackRate(min(1.2, st.getPlaybackRate() + 0.05)))
+
+ ui.slider(min=0, max=100, value=0)
+
+ with ui.row().classes("w-full justify-between no-wrap"):
+ ui.button('Prev', on_click=st.previousSong)
+ ui.button('-25%', on_click=_createSeekHandler(-0.25))
+ ui.button('-5%', on_click=_createSeekHandler(-0.05))
+ ui.button('-1%', on_click=_createSeekHandler(-0.01))
+ ui.button('+1%', on_click=_createSeekHandler(0.01))
+ ui.button('+5%', on_click=_createSeekHandler(0.05))
+ ui.button('+25%', on_click=_createSeekHandler(0.25))
+ ui.button('Next', on_click=st.nextSong)
+
+ with ui.row().classes("w-full justify-between no-wrap"):
+ ui.button('Set A')
+ ui.button('Set B')
+ ui.button('Previous AB')
+ ui.button('Next AB')
+
+ with ui.row().classes("w-full justify-between no-wrap"):
+ ui.button('Toggle AB', on_click=lambda: st.setAbLimitEnable(not st.isAbLimitEnabled()))
+ ui.button('Stop', on_click=st.stop)
+ ui.button('Play', on_click=st.play)
+ ui.button('Jump to A', on_click=st.jumpToA)
ui.run()
if __name__ in {'__main__', '__mp_main__'}: