Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::: Pass The Desired Music File Path and Volume to this .bat program Using CALL and Variables.
- ::: This Script is designed for Looping Music.
- ::: To play a sound without Looping:
- ::: -SUBSTITUTE- Sound.settings.setMode "loop", True -WITH- Sound.settings.setMode "loop", False
- :::
- ::: Example:
- :::
- ::: Set track=%userprofile%\foldername\songname.mp3
- ::: Set Vol=50
- ::: Set MusicPlayer=%userprofile%\foldername\MusicPlayer.bat
- ::: CALL "%MusicPlayer%" %track% %vol%
- ::: %track% is the 1st Arguement, %vol% is the 2nd Arguement.
- :::
- ::: If you wish to control Looping from the calling program, Set a Variable for Looping & pass a 3rd agruement with CALL.
- :::
- ::: Example:
- ::: Before Calling MusicPlayer, Set "loopIs=true" -OR- Set "loopIs=false" as desired.
- ::: CALL "%MusicPlayer%" %track% %vol% %loopIs%
- :::
- ::: Then, below the following two Variables, Set loopis=%~3
- ::: Lastly, -SUBSTITUTE- Sound.settings.setMode "loop", True -WITH- Sound.settings.setMode "loop", %loopis%
- :::
- ::: To Stop the Music, Call another .bat with this in it:
- :::
- ::: @ECHO OFF
- ::: taskkill /pid WScript.exe /f /t >nul
- ::: GOTO :EOF
- @ECHO OFF
- Set "MusicPath=%~1"
- Set vol=%~2
- ::: Change to the Directory you want to create the Music Launcher in.
- PUSHD %sounds%
- ::: Ensure no Conflict with the Previous Script.
- IF exist PlayMusic.vbs (
- DEL PlayMusic.vbs
- )
- ::: Creates a vbs Script to launch the music (Occurs without any visual indication or prompting)
- ( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
- echo Sound.URL = "%MusicPath%"
- echo Sound.settings.volume = %vol%
- echo Sound.settings.setMode "loop", True
- echo Sound.Controls.play
- echo While Sound.playState ^<^> 1
- echo WScript.Sleep 100
- echo Wend
- )>PlayMusic.vbs
- start /min PlayMusic.vbs
- ::: Return to the Previous Directory
- POPD
- ::: Exit the Launcher and return to Previous batch program.
- GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment