Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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 is setup. They also must be in order with each other.
- // 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"
- ]
- musicMainMenuName = (concatword (yellow) "Music " (green) Player)
- genMusicMainMenu = [
- delmenu $musicMainMenuName
- newmenu $musicMainMenuName
- menuitem (concat (green) Now Playing) [ nowPlayingMenu ]
- menuitem "" -1
- menuitem (concat (blue) ~ Music Library ~) -1
- menuitem "" -1
- genSongList
- ]
- genSongList = [
- loop gm (listlen $songLibraryNames) [
- 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)
- ]
- ]
- 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 3) (yellow) / (listlen $songLibrary)))
- ] [
- if (= $songPosition (- (listlen $songLibrary) 1)) [
- menuitem (concat Track Number: (yellow) Last (concatword (addpunct (listlen $songLibrary) 3) (yellow) / (listlen $songLibrary)))
- ] [
- 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 ]
- menuitem (concat (blue) Previous Song In Library) [ skipSong -1 ]
- menuitem (concat (orange) Shuffle) [ shuffleSongs ]
- 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 [
- menuitem "" -1
- menuitem (concat (purple) Active Modes: (white)Shuffle)
- menuitem (concat (red) Turn Shuffle Off) [ stopShuffle ]
- ]
- sleep 1 [ showmenu "Now Playing" ]
- ]
- playSong = [
- if (> (findlist $songLibrary $arg1) -1) [
- if (strcmp $arg3 shuffle) [
- echo umhmmmmmm ":)"
- shuffling = 1
- music $arg1 $arg2 [ if $musicPlayerLoopShuffle [ shuffleSongs ] [ if $musicPlayerRepeat [ repeatLastPlayedSong ]; shuffling = 0 ] ]
- ] [
- music $arg1 $arg2 [ if $musicPlayerRepeat [ repeatLastPlayedSong ] ]
- ]
- musicstopped = 0
- lastPlayedSong = (concat $arg1 $arg2)
- 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 [ tmpSongPos = (- (listlen $songLibrary) 1) ] [
- += tmpSongPos 2
- ]
- ] [
- if (= $tmpSongPos (listlen $songLibrary)) [
- if $wrapAround [ tmpSongPos = 0 ] [
- -= tmpSongPos 2
- ]
- ]
- ]
- if (&& (> $tmpSongPos -1) (< $tmpSongPos (listlen $songLibrary))) [
- playSong (at $songLibrary $tmpSongPos) (at $songLengths $tmpSongPos)
- ]
- ]
- inAlreadyPlayed = [
- yep = 0
- loop ia (listlen $alreadyPlayed) [
- if (= (at $alreadyPlayed $ia) $arg1) [ yep = 1; break ]
- ]
- result $yep
- ]
- shuffleSongs = [
- randomSongPos = (rnd (listlen $songLibrary))
- echo Chosen Random Position: (concatword $randomSongPos / (- (listlen $songLibrary) 1))
- if (= (listlen $alreadyPlayed) (listlen $songLibrary)) [ alreadyPlayed = "" ]
- if (&& (inAlreadyPlayed $randomSongPos) (listlen $alreadyPlayed)) [ echo retrying shuffle; shuffleSongs ] [
- sleep 1000 [ playSong (at $songLibrary $randomSongPos) (at $songLibrary $randomSongPos) shuffle ] // FIXME ???
- add2list alreadyPlayed $randomSongPos
- ]
- ]
- stopShuffle = [
- music
- shuffling = 0
- showmenu $musicMainMenuName
- ]
- 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" ""
- reset "shuffling" 0
- reset "musicstopped" 1
- resetc "musicPlayerRepeat musicNowPlayingPopup" 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
Advertisement