Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.87 KB | None | 0 0
  1. // How to use:
  2. //
  3. // * Put .ogg audio files that you want in your music library into /packages/audio/soundtracks/
  4. // * Edit the following aliases:
  5. //    songLibrary
  6. //    songLengths
  7. //    songLibraryNames
  8. //    songLibraryArtists
  9. //   These aliases determine how the Music Player menu is setup. They also must be in order with each other.
  10.  
  11. // songLibrary - List of music file names in /packages/audio/soundtracks/ without the ".ogg" extension.
  12. songLibrary = [
  13.   song_file_name_1
  14.   song_file_name_2
  15.   song_file_name_3
  16.   song_file_name_4
  17.   song_file_name_5
  18. ]
  19.  
  20. // songLengths - List of lengths (in milliseconds) of the music files listed above.
  21. songLengths = [
  22.   250000
  23.   234000
  24.   269000
  25.   258000
  26.   299000
  27. ]
  28.  
  29. // songLibraryNames - List of song titles of the music files listed above.
  30. songLibraryNames = [
  31.   "Song Title 1"
  32.   "Song Title 2"
  33.   "Song Title 3"
  34.   "Song Title 4"
  35.   "Song Title 5"
  36. ]
  37.  
  38. // songLibraryArtists - List of song artists of the music files above.
  39. songLibraryArtists = [
  40.   "Song Artist 1"
  41.   "Song Artist 2"
  42.   "Song Artist 3"
  43.   "Song Artist 4"
  44.   "Song Artist 5"
  45. ]
  46.  
  47. musicMainMenuName = (concatword (yellow) "Music " (green) Player)
  48.  
  49. genMusicMainMenu = [
  50.   delmenu $musicMainMenuName
  51.   newmenu $musicMainMenuName
  52.   menuitem (concat (green) Now Playing) [ nowPlayingMenu ]
  53.   menuitem "" -1
  54.   menuitem (concat (blue) ~ Music Library ~) -1
  55.   menuitem "" -1
  56.   genSongList
  57. ]
  58.  
  59. genSongList = [
  60.   loop gm (listlen $songLibraryNames) [
  61.     menuitem (concatword (blue) (at $songLibraryArtists $gm) (gray) " - " (yellow) (at $songLibraryNames $gm)) [ playSong (at $lastmusicsel 0) (at $lastmusicsel 1) ] (addpunct (concat alias lastmusicsel (addpunct (concat (at $songLibrary $gm) (at $songLengths $gm)))) 2)
  62.   ]
  63. ]
  64.  
  65. nowPlayingMenu = [
  66.   closemenu "Now Playing"
  67.   delmenu "Now Playing"
  68.   newmenu "Now Playing"
  69.   songPosition = (findlist $songLibrary (at $lastPlayedSong 0))
  70.   if (&& (> $songPosition -1) (! $musicstopped)) [
  71.     menuitem (concat (green) Now playing: (blue) (at $songLibraryArtists $songPosition) (gray) - (yellow) (at $songLibraryNames $songPosition)) -1
  72.     if (= $songPosition 0) [
  73.       menuitem (concat Track Number: (yellow) First (concatword (addpunct 0 3) (yellow) / (listlen $songLibrary)))
  74.     ] [
  75.       if (= $songPosition (- (listlen $songLibrary) 1)) [
  76.         menuitem (concat Track Number: (yellow) Last (concatword (addpunct (listlen $songLibrary) 3) (yellow) / (listlen $songLibrary)))
  77.       ] [
  78.         menuitem (concat Track Number: (yellow) (concatword (+ $songPosition 1) / (listlen $songLibrary))) -1
  79.       ]
  80.     ]
  81.   ] [
  82.     menuitem (concat (green) Now playing: (gray) None) -1
  83.   ]
  84.   menuitem (concat (green) Play) [ repeatLastPlayedSong ]
  85.   menuitem (concat (red) Stop) [ music; musicstopped = 1; showmenu $musicMainMenuName ]
  86.   menuitem (concat (yellow) Next Song in Library) [ skipSong 1 ]
  87.   menuitem (concat (blue) Previous Song In Library) [ skipSong -1 ]
  88.   menuitem (concat (orange) Shuffle) [ shuffleSongs ]
  89.   menuitemcheckbox "Repeat: " "$musicPlayerRepeat"[ musicPlayerRepeat = $arg1 ]
  90.   menuitemslider "Music Volume: " 0 255 "$musicvol" 10 [] [ musicvol $arg1 ]
  91.   menuitemslider "Sound Volume: " 0 255 "$soundvol" 10 [] [ soundvol $arg1 ]
  92.   if $shuffling [
  93.     menuitem "" -1
  94.     menuitem (concat (purple) Active Modes: (white)Shuffle)
  95.     menuitem (concat (red) Turn Shuffle Off) [ stopShuffle ]
  96.   ]
  97.   sleep 1 [ showmenu "Now Playing" ]
  98. ]
  99.  
  100. playSong = [
  101.   if (> (findlist $songLibrary $arg1) -1) [
  102.     if (strcmp $arg3 shuffle) [
  103.       echo umhmmmmmm ":)"
  104.       shuffling = 1
  105.       music $arg1 $arg2 [ if $musicPlayerLoopShuffle [ shuffleSongs ] [ if $musicPlayerRepeat [ repeatLastPlayedSong ]; shuffling = 0 ] ]
  106.     ] [
  107.       music $arg1 $arg2 [ if $musicPlayerRepeat [ repeatLastPlayedSong ] ]
  108.     ]
  109.     musicstopped = 0
  110.     lastPlayedSong = (concat $arg1 $arg2)
  111.     nowPlayingMenu
  112.   ]
  113. ]
  114.  
  115. repeatLastPlayedSong = [
  116.   if (checkalias lastPlayedSong) [
  117.     playSong (at $lastPlayedSong 0) (at $lastPlayedSong 1)
  118.   ]
  119. ]
  120.  
  121. skipSong = [
  122.   tmpSongPos = (findlist $songLibrary (at $lastPlayedSong 0))
  123.   if (= $arg1 -1) [ -= tmpSongPos 1 ] [ += tmpSongPos 1 ]
  124.   if (= $tmpSongPos -1) [
  125.     if $wrapAround [ tmpSongPos = (- (listlen $songLibrary) 1) ] [
  126.       += tmpSongPos 2
  127.     ]
  128.   ] [
  129.     if (= $tmpSongPos (listlen $songLibrary)) [
  130.       if $wrapAround [ tmpSongPos = 0 ] [
  131.         -= tmpSongPos 2
  132.       ]
  133.     ]
  134.   ]
  135.   if (&& (> $tmpSongPos -1) (< $tmpSongPos (listlen $songLibrary))) [
  136.     playSong (at $songLibrary $tmpSongPos) (at $songLengths $tmpSongPos)
  137.   ]
  138. ]
  139.  
  140. inAlreadyPlayed = [
  141.   yep = 0
  142.   loop ia (listlen $alreadyPlayed) [
  143.     if (= (at $alreadyPlayed $ia) $arg1) [ yep = 1; break ]
  144.   ]
  145.   result $yep
  146. ]
  147.  
  148. shuffleSongs = [
  149.   randomSongPos = (rnd (listlen $songLibrary))
  150.   echo Chosen Random Position: (concatword $randomSongPos / (- (listlen $songLibrary) 1))
  151.   if (= (listlen $alreadyPlayed) (listlen $songLibrary)) [ alreadyPlayed = "" ]
  152.   if (&& (inAlreadyPlayed $randomSongPos) (listlen $alreadyPlayed)) [ echo retrying shuffle; shuffleSongs ] [
  153.     sleep 1000 [ playSong (at $songLibrary $randomSongPos) (at $songLibrary $randomSongPos) shuffle ] // FIXME ???
  154.     add2list alreadyPlayed $randomSongPos
  155.   ]
  156. ]
  157.  
  158. stopShuffle = [
  159.   music
  160.   shuffling = 0
  161.   showmenu $musicMainMenuName
  162. ]
  163.  
  164. reset  = [ loop za (listlen $arg1) [ (at $arg1 $za) = $arg2 ] ]
  165. resetc = [ loop za (listlen $arg1) [ if (! (checkalias (at $arg1 $za))) [ (at $arg1 $za) = $arg2 ] ] ]
  166.  
  167. reset "alreadyPlayed" ""
  168. reset "shuffling" 0
  169. reset "musicstopped" 1
  170. resetc "musicPlayerRepeat musicNowPlayingPopup" 0
  171. resetc "wrapAround musicPlayerLoopShuffle" 1
  172.  
  173. genMusicMainMenu
  174.  
  175. addListOnQuit "songLibrary songLengths songLibraryNames songLibraryArtists musicMainMenuName genMusicMainMenu genSongList nowPlayingMenu playSong repeatLastPlayedSong skipSong lastPlayedSong lastmusicsel tmpSongPos musicstopped songPosition reset resetc"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement