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'): for song in st.getSongs(): ui.item(song) with splitter.after: 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__'}: main()