T3RRYT3RR0R

Batch Music Launcher

Dec 10th, 2019
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.88 KB | None | 0 0
  1. ::: Pass The Desired Music File Path and Volume to this .bat program Using CALL and Variables.
  2. ::: This Script is designed for Looping Music.
  3. ::: To play a sound without Looping:
  4. ::: -SUBSTITUTE- Sound.settings.setMode "loop", True -WITH- Sound.settings.setMode "loop", False
  5. :::
  6. ::: Example:
  7. :::
  8. ::: Set track=%userprofile%\foldername\songname.mp3
  9. ::: Set Vol=50
  10. ::: Set MusicPlayer=%userprofile%\foldername\MusicPlayer.bat
  11. ::: CALL "%MusicPlayer%" %track% %vol%
  12. ::: %track% is the 1st Arguement, %vol% is the 2nd Arguement.
  13. :::
  14. ::: If you wish to control Looping from the calling program, Set a Variable for Looping & pass a 3rd agruement with CALL.
  15. :::
  16. ::: Example:
  17. ::: Before Calling MusicPlayer, Set "loopIs=true" -OR- Set "loopIs=false" as desired.
  18. ::: CALL "%MusicPlayer%" %track% %vol% %loopIs%
  19. :::
  20. ::: Then, below the following two Variables, Set loopis=%~3
  21. ::: Lastly, -SUBSTITUTE- Sound.settings.setMode "loop", True -WITH- Sound.settings.setMode "loop", %loopis%
  22. :::
  23. ::: To Stop the Music, Call another .bat with this in it:
  24. :::
  25. ::: @ECHO OFF
  26. ::: taskkill /pid WScript.exe /f /t >nul
  27. ::: GOTO :EOF
  28.  
  29. @ECHO OFF
  30.  
  31. Set "MusicPath=%~1"
  32. Set vol=%~2
  33.  
  34. ::: Change to the Directory you want to create the Music Launcher in.
  35.  
  36. PUSHD %sounds%
  37.  
  38. ::: Ensure no Conflict with the Previous Script.
  39.  
  40. IF exist PlayMusic.vbs (
  41. DEL PlayMusic.vbs
  42. )
  43.  
  44. ::: Creates a vbs Script to launch the music (Occurs without any visual indication or prompting)
  45.  
  46. ( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
  47.   echo Sound.URL = "%MusicPath%"
  48.   echo Sound.settings.volume = %vol%
  49.   echo Sound.settings.setMode "loop", True
  50.   echo Sound.Controls.play
  51.   echo While Sound.playState ^<^> 1
  52.   echo      WScript.Sleep 100
  53.   echo Wend
  54. )>PlayMusic.vbs
  55. start /min PlayMusic.vbs
  56.  
  57. ::: Return to the Previous Directory
  58.  
  59. POPD
  60.  
  61. ::: Exit the Launcher and return to Previous batch program.
  62.  
  63. GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment