Advertisement
RaZgRiZ

MusicBrowser (GUI)

Jun 13th, 2020
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. // THE FOLLOWING 3 ARE ALREADY IMPLEMENTED IN SOURCE IN SVN
  2. floor = [+ 0 $arg1]
  3. ceil  = [
  4.     if (!=f (floor $arg1) $arg1) [
  5.         if (>=f $arg1 0.0) [+ $arg1 1] [- $arg1 1]
  6.     ] [ result $arg1 ]
  7. ]
  8. append = [ nodebug [ $arg1 = (concat $$arg1 $arg2) ] ]
  9.  
  10. // usage: (breaklist [ LIST ] <PARTS>)
  11. breaklist = [
  12.     loopconcat i (ceil (divf (listlen $arg1) $arg2)) [
  13.         result [[@@(sublist $arg1 (* $i $arg2) $arg2)]]
  14.     ]
  15. ]
  16. init = [ nodebug [ if (=s $$arg1 "") [ $arg1 = $arg2 ] ] ]
  17.  
  18.  
  19. init songlist
  20. init songlistloop
  21. init songcurrent
  22.  
  23. showmusicbrowser = [
  24.     songlist = []
  25.     loopfiles f "packages/fanatic" "ogg" [ append songlist (escape $f) ]
  26.     songlist = (sortlist $songlist a b [<s $a $b])
  27.     looplist n $songlistloop [
  28.         if (< (indexof $songlist $n) 0) []
  29.     ]
  30.     songlistloop = (listdel $songlistloop (
  31.         loopconcat n (listlen $songlistloop) [
  32.             ? (< (indexof $songlist (at $songlistloop $n)) 0) [at $songlistloop $n]
  33.         ]
  34.     ))
  35.     songlist = (breaklist $songlist 15)
  36.     showgui "musicbrowser"
  37. ]
  38.  
  39. playasong = [
  40.     if $numargs [
  41.         songcurrent = $arg1
  42.         echo "^f7Now playing:^f2" $songcurrent
  43.     ] [
  44.         local len ; len = (listlen $songlistloop)
  45.         if $len [
  46.             songcurrent = (at $songlistloop (mod (+ (indexof $songlistloop $songcurrent) 1) $len))
  47.             echo "^f7Now playing next queue song:^f2" $songcurrent
  48.  
  49.         ] [
  50.             songcurrent = (at $songlist (rnd (listlen $songlist)))
  51.             songcurrent = (at $songcurrent (rnd (listlen $songcurrent)))
  52.             echo "^f7Now playing random song:^f2" $songcurrent
  53.         ]
  54.     ]
  55.     music (concatword "fanatic/" (unescape $songcurrent) ".ogg") [ playasong ]
  56. ]
  57.  
  58. newgui "musicbrowser" [
  59.     guistayopen [
  60.         loop p (listlen $songlist) [
  61.             if $p [ guitab (concatword " " $p " ") ]
  62.             guilist [
  63.                 guitext (concat"^f7Total songs in loop:^f2" (listlen $songlistloop))
  64.                 guispring
  65.                 guibutton "" [ songlistloop = [] ] "exit"
  66.             ]
  67.             guibar
  68.             looplist n (at $songlist $p) [
  69.                 guilist [
  70.                     if (< (indexof $songlistloop $n) 0) [
  71.                         guibutton "  " [ append songlistloop (escape [@@(unescape $n)]) ; echo $songlistloop] "checkbox_off"
  72.                     ] [ guibutton "  " [ songlistloop = (listdel $songlistloop (escape [@@(unescape $n)])) ; echo $songlistloop] "radio_on" ]
  73.                     guilist [
  74.                         guistrut 30 1
  75.                         guibutton (concatword "^f2" (strreplace (unescape $n) "-" "^f7-")) [ playasong (unescape [@@n]) ] 0
  76.                     ]
  77.                 ]
  78.             ]
  79.         ]
  80.     ]
  81. ] "Music Browser"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement