node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,58 @@
package mpchc
import "strconv"
func (api *MpcHc) Play() (err error) {
_, err = api.Execute(playCmd, nil)
return
}
func (api *MpcHc) Pause() (err error) {
_, err = api.Execute(pauseCmd, nil)
return
}
func (api *MpcHc) TogglePlay() (err error) {
_, err = api.Execute(playPauseCmd, nil)
return
}
func (api *MpcHc) Stop() (err error) {
_, err = api.Execute(stopCmd, nil)
return
}
func (api *MpcHc) ToggleFullScreen() (err error) {
_, err = api.Execute(fullscreenCmd, nil)
return
}
// Seek position in ms
func (api *MpcHc) Seek(pos int) (err error) {
_, err = api.Execute(seekCmd, map[string]interface{}{"position": millisecondsToDuration(pos)})
return
}
//----------------------------------------------------------------------------------------------------------------------
func millisecondsToDuration(ms int) string {
if ms <= 0 {
return "00:00:00"
}
duration := ms / 1000
hours := duration / 3600
duration %= 3600
minutes := duration / 60
duration %= 60
return padStart(strconv.Itoa(hours), 2, "0") + ":" + padStart(strconv.Itoa(minutes), 2, "0") + ":" + padStart(strconv.Itoa(duration), 2, "0")
}
func padStart(s string, length int, pad string) string {
for len(s) < length {
s = pad + s
}
return s
}