gpt4 book ai didi

batch-file - 批量退出时停止背景音频以及如何定界循环

转载 作者:行者123 更新时间:2023-12-02 23:41:49 25 4
gpt4 key购买 nike

好吧,我从Batch开始,我想知道如何在不使用任务管理器退出.bat文件时停止执行的背景音频。我正在使用它执行音频并循环播放:

set "file=music1.mp3"
( echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%file%"
echo Sound.settings.volume = 100
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>sound.vbs
start /min sound.vbs

另一个问题是如何分隔循环,因为我不知道如何在一定数量的循环处停止循环。先感谢您。

最佳答案

该代码的灵感源于此:How do I play music on loop in batch?

@echo off
Title Play Music in loop and stop it
Call:StopMusic
echo We play "Intro_DJ.mp3" with a volume of 80
Call:PlayMusic http://hackoo.alwaysdata.net/Intro_DJ.mp3 80
echo(
echo Hit any key to stop the music and play another file
pause>nul
Call:StopMusic
cls
Call:PlayMusic http://hackoo.alwaysdata.net/Matrix.mp3 100
echo(
echo We play "Matrix.mp3" with a volume of 100
echo(
echo Hit any key to stop the music in loop
pause>nul
Call:StopMusic
Exit /b
::************************************************************
:PlayMusic <Media_URL> <Volume>
(
echo Set Sound = CreateObject("WMPlayer.OCX.7"^)
echo Sound.URL = "%1"
echo Sound.settings.volume = %2
echo Sound.settings.setMode "loop", True
echo Sound.Controls.play
echo While Sound.playState ^<^> 1
echo WScript.Sleep 100
echo Wend
)>%~n0.vbs
start "" "%~n0.vbs" %1 %2
Exit /b
::************************************************************
:StopMusic
Taskkill /IM "wscript.exe" /F>nul 2>&1
Exit /b
::************************************************************

关于batch-file - 批量退出时停止背景音频以及如何定界循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37230789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com