menu channel {
My MP3s
.Song - $iif($insong, $nopath($insong.fname), Nothing Playing) :/halt
.Position - $mp3pos :/halt
.-
.Stop Playing: /splay stop
.Pause Song: /splay pause
.Resume Playing: /splay resume
.-
.$submenu($mp3list($$1))
}
alias mp3list {
var %mp3dir = $shortfn([color:Red]C:\Music[/color])
if ($$1 == begin) return -
else if ($$1 == end) return -
else if ($findfile(%mp3dir, *.mp3, $$1, 0)) return $nopath($ifmatch) : /splay -p $ifmatch
}
alias mp3pos {
var %barlength = 15
if ($insong) {
var %length = $sound($insong.fname).length, %pos = $insong.pos, %left = $int($calc((%pos / %length) * %barlength))
var %pos = $remove($replace($duration($calc($insong.pos / 1000)), mins, m, min, m, secs, s, sec, s), $chr(32))
var %len = $remove($replace($duration($calc($sound($insong.fname).length / 1000)), mins, m, min, m, secs, s, sec, s), $chr(32))
var %time = ( $+ %pos $+ / $+ %len $+ )
}
else var %left = 0
return [[ $+ $str($chr(124), %left) $+ $str(-, $calc(%barlength - %left)) $+ ]] %time
}