Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ACMP (AC Music Player) Beta by Bukz - (currently SVN only)
- // How to use:
- //
- // * Put .ogg audio files that you want in your music library into /packages/audio/soundtracks/
- // * Edit the following aliases:
- // songLibrary
- // songLengths
- // songLibraryNames
- // songLibraryArtists
- // These aliases determine how the Music Player menu and your music library is setup.
- // They MUST be in order with each other. (e.g. Item #1 of "songLibrary" corresponds
- // with item #1 of "songLengths" and so on.)
- // For easy access to the script's main menu, uncomment and edit the keybind below:
- // bind KEY [ showmenu $musicMainMenuName ]
- //
- // OR, execute the following command in-game at anytime to view the script's main menu:
- //
- // /showmenu $musicMainMenuName
- // Basic features:
- //
- // A song library to put all of your favorite songs into for easy access in-game at anytime.
- // Loop Library (aka Repeat Library/Playlist in order.)
- // Shuffle (w/ optional "Loop Shuffle" - a continuous loop of random songs.)
- // Repeat Track
- // Play
- // Stop
- // Next
- // Previous
- // Main Song Library Menu (w/ individual menuitems to play each song in your song library.)
- // Now Playing Menu
- // Settings Menu to tweak the script's behavior. (w/ debug mode.)
- // START EDITING YOUR MUSIC LIBRARY BELOW
- // songLibrary - List of music file names in /packages/audio/soundtracks/ without the ".ogg" extension.
- songLibrary = [
- song_file_name_1
- song_file_name_2
- song_file_name_3
- song_file_name_4
- song_file_name_5
- ]
- // songLengths - List of lengths (in milliseconds) of the music files listed above.
- songLengths = [
- 250000
- 234000
- 269000
- 258000
- 299000
- ]
- // songLibraryNames - List of song titles of the music files listed above.
- songLibraryNames = [
- "Song Title 1"
- "Song Title 2"
- "Song Title 3"
- "Song Title 4"
- "Song Title 5"
- ]
- // songLibraryArtists - List of song artists of the music files above.
- songLibraryArtists = [
- "Song Artist 1"
- "Song Artist 2"
- "Song Artist 3"
- "Song Artist 4"
- "Song Artist 5"
- ]
- // STOP EDITING MUSIC LIBRARY
- musicMainMenuName = (concatword (yellow) "Music " (green) Player (white))
- genMusicMainMenu = [
- if $musicDebugMode [ echo (blue)Debug: (white)Music Player Main Menu generating... ]
- delmenu $musicMainMenuName
- newmenu $musicMainMenuName
- menuitem (concat (green) Now Playing) [ nowPlayingMenu ]
- menuitem (concat (orange) Settings) [ showmenu "Music Player Settings" ]
- menuitem "" -1
- menuitem (concat (blue) ~ Music Library ~) -1
- menuitem "" -1
- genSongList
- if $musicDebugMode [ echo (blue)Debug: (white)Done generating Main Menu. ]
- ]
- genSongList = [
- loop gm (listlen $songLibraryNames) [
- if $musicDebugMode [ echo (blue)Debug: (white)Generating menu item for song - (at $songLibrary $gm) ]
- 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)
- ]
- if $musicDebugMode [ echo (blue)Debug: (white)Done generating Main Menu song menu items. ]
- ]
- nowPlayingMenu = [
- closemenu "Now Playing"
- delmenu "Now Playing"
- newmenu "Now Playing"
- songPosition = (findlist $songLibrary (at $lastPlayedSong 0))
- if (&& (> $songPosition -1) (! $musicstopped)) [
- menuitem (concat (green) Now playing: (blue) (at $songLibraryArtists $songPosition) (gray) - (yellow) (at $songLibraryNames $songPosition)) -1
- if (= $songPosition 0) [
- menuitem (concat Track Number: (yellow) First (concatword (addpunct 0 2) (yellow) / (listlen $songLibrary))) -1
- ] [
- if (= $songPosition (- (listlen $songLibrary) 1)) [
- menuitem (concat Track Number: (yellow) Last (concatword (addpunct (listlen $songLibrary) 2) (yellow) / (listlen $songLibrary))) -1
- ] [
- menuitem (concat Track Number: (yellow) (concatword (+ $songPosition 1) / (listlen $songLibrary))) -1
- ]
- ]
- ] [
- menuitem (concat (green) Now playing: (gray) None) -1
- ]
- menuitem (concat (green) Play) [ repeatLastPlayedSong ]
- menuitem (concat (red) Stop) [ music; musicstopped = 1; showmenu $musicMainMenuName ]
- menuitem (concat (yellow) Next Song in Library) [ skipSong 1; nowPlayingMenu ]
- menuitem (concat (blue) Previous Song In Library) [ skipSong -1; nowPlayingMenu ]
- menuitem (concat (orange) Shuffle) [ shuffleSongs; nowPlayingMenu ]
- menuitem (concat (green) Loop Library) [ loopLib; nowPlayingMenu ]
- menuitem (concat (yellow) Refresh Now Playing) [ nowPlayingMenu ]
- menuitem Back [ showmenu $musicMainMenuName ]
- menuitem "" -1
- menuitemcheckbox "Repeat: " "$musicPlayerRepeat"[ musicPlayerRepeat = $arg1 ]
- menuitemslider "Music Volume: " 0 255 "$musicvol" 10 [] [ musicvol $arg1 ]
- menuitemslider "Sound Volume: " 0 255 "$soundvol" 10 [] [ soundvol $arg1 ]
- if (|| $shuffling $musicPlayerLoopLib) [
- if $musicDebugMode [ echo (blue)Debug: (white)Special playback mode active, generating menuitems... ]
- menuitem "" -1
- if (&& $shuffling (! $musicPlayerLoopLib)) [ menuitem (concat (purple) Active Modes: (white)Shuffle) ] [
- if (&& $musicPlayerLoopLib (! $shuffling)) [ menuitem (concat (purple) Active Modes: (white)Loop) ] [
- menuitem (concat (purple) Active Modes: Loop, Shuffle)
- ]
- ]
- if $shuffling [ menuitem (concat (red) Turn Shuffle Off) [ shuffling = 0; showmenu $musicMainMenuName ] ]
- if $musicPlayerLoopLib [ menuitem (concat (red) Turn Loop Off) [ musicPlayerLoopLib = 0; showmenu $musicMainMenuName ] ]
- ]
- sleep 1 [ showmenu "Now Playing" ]
- ]
- playSong = [
- if (> (findlist $songLibrary $arg1) -1) [
- tmpSongInfo = (concat $arg1 $arg2)
- if (strcmp $arg3 loop) [
- if $musicDebugMode [ echo (blue)Debug: (white)Initiating song library loop... ]
- music $arg1 $arg2 [ if $musicPlayerLoopLib [ skipSong 1 ] [ if $musicPlayerRepeat [ repeatLastPlayedSong ]; musicPlayerLoopLib = 0 ] ]
- ] [
- if (strcmp $arg3 shuffle) [
- if $musicDebugMode [ echo (blue)Debug: (white)Executing shuffle... ]
- shuffling = 1
- music $arg1 $arg2 [ if $musicPlayerLoopShuffle [ shuffleSongs ] [ if $musicPlayerRepeat [ repeatLastPlayedSong ]; shuffling = 0 ] ]
- ] [
- music $arg1 $arg2 [ if $musicPlayerRepeat [ repeatLastPlayedSong ] ]
- ]
- ]
- musicstopped = 0
- lastPlayedSong = $tmpSongInfo
- if $musicNowPlayingPopup [ nowPlayingMenu ]
- ]
- ]
- repeatLastPlayedSong = [
- if (checkalias lastPlayedSong) [
- playSong (at $lastPlayedSong 0) (at $lastPlayedSong 1)
- ]
- ]
- skipSong = [
- tmpSongPos = (findlist $songLibrary (at $lastPlayedSong 0))
- if (= $arg1 -1) [ -= tmpSongPos 1 ] [ += tmpSongPos 1 ]
- if (= $tmpSongPos -1) [
- if (|| $wrapAround $musicPlayerLoopLib) [ tmpSongPos = (- (listlen $songLibrary) 1); if $musicDebugMode [ echo (blue)Debug: (white)Wrapping down... ] ] [
- if $musicDebugMode [ echo (blue)Debug: (white)First song, skipSong going to next track instead. ]
- += tmpSongPos 2
- ]
- ] [
- if (= $tmpSongPos (listlen $songLibrary)) [
- if (|| $wrapAround $musicPlayerLoopLib) [ tmpSongPos = 0; if $musicDebugMode [ echo (blue)Debug: (white)Wrapping up... ] ] [
- if $musicDebugMode [ echo (blue)Debug: (white)Last song, skipSong going to previous track instead. ]
- -= tmpSongPos 2
- ]
- ]
- ]
- if (&& (> $tmpSongPos -1) (< $tmpSongPos (listlen $songLibrary))) [
- if $musicPlayerLoopLib [ playSong (at $songLibrary $tmpSongPos) (at $songLengths $tmpSongPos) loop ] [
- playSong (at $songLibrary $tmpSongPos) (at $songLengths $tmpSongPos)
- ]
- ] [ if $musicDebugMode [ echo (blue)Debug: (white)skipSong could not find a valid song to play. ] ]
- ]
- loopLib = [
- if (listlen $songLibrary) [
- musicPlayerLoopLib = 1
- playSong (at $songLibrary 0) (at $songLengths 0) loop
- ]
- ]
- wasAlreadyPlayed = [
- yep = 0
- if (= (listlen $alreadyPlayed) (listlen $songLibrary)) [
- alreadyPlayed = ""
- if $musicDebugMode [ echo (blue)Debug: (white)Resetting alreadyPlayed list. ]
- result 0
- ] [
- loop fd (listlen $alreadyPlayed) [
- if (strcmp (at $alreadyPlayed $fd) (at $songLibrary $arg1)) [ yep = 1; break ]
- ]
- if $yep [ if $musicDebugMode [ echo (blue)Debug: (white)Track (at $songLibrary $arg1) was already played. Trying again... ] ]
- result $yep
- ]
- ]
- getValidSongInt = [
- tmpRandomSong = (rrnd 0 (listlen $songLibrary))
- if (wasAlreadyPlayed $tmpRandomSong) [ getValidSongInt ] [
- result $tmpRandomSong
- ]
- ]
- shuffleSongs = [
- randomSongPos = (getValidSongInt)
- if $musicDebugMode [ echo (blue)Debug: (white)Chosen Random Position: (concatword $randomSongPos / (- (listlen $songLibrary) 1)) ]
- playSong (at $songLibrary $randomSongPos) (at $songLengths $randomSongPos) shuffle
- add2list alreadyPlayed (at $songLibrary $randomSongPos)
- ]
- newmenu "Music Player Settings"
- menuitemcheckbox "Loop Shuffle: " "$musicPlayerLoopShuffle" [ musicPlayerLoopShuffle = $arg1 ]
- menuitemcheckbox "Pop-up Now Playing on new song: " "$musicNowPlayingPopup" [ musicNowPlayingPopup = $arg1 ]
- menuitemcheckbox "Next/Previous track library wrap around: " "$wrapAround" [ wrapAround = $arg1 ]
- menuitemcheckbox "Debug Mode: " "$musicDebugMode" [ musicDebugMode = $arg1 ]
- reset = [ loop za (listlen $arg1) [ (at $arg1 $za) = $arg2 ] ]
- resetc = [ loop za (listlen $arg1) [ if (! (checkalias (at $arg1 $za))) [ (at $arg1 $za) = $arg2 ] ] ]
- reset "alreadyPlayed lastPlayedSong" ""
- reset "shuffling musicPlayerLoopLib" 0
- reset "musicstopped" 1
- resetc "musicPlayerRepeat musicNowPlayingPopup musicDebugMode" 0
- resetc "wrapAround musicPlayerLoopShuffle" 1
- genMusicMainMenu
- 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