如何检测媒体播放器是否已停止播放?
请为Windows Media Player回答。我需要它通过cmd\bat进行检测。
我需要做的就是在播放播放列表后关闭Windows Media Player。所以
到目前为止,我有:
start wmplayer.exe /play /playlist "NiteTime Listener Playlist"
基本上,我正在编写一个程序,可以在其中放置某些文件
在Windows Media Player中播放列表,然后打开该程序,然后播放所有
文件,然后关闭PC。
到目前为止,我已经设置了启动WMP(Windows Media Player),播放“播放列表”,然后检测WMP是否打开的功能,如果没有打开,它将关闭PC。
如果是,它将再次循环检测。
唯一的问题是播放列表完成后关闭WMP。
这是我的整个代码:
@echo off
title Automatic Shutdown for NiteTime Listener
echo To cancel Shutdown, close this program before Player.
start mplayer2.exe /play /Playlist "NiteTime Listener Playlist"
:testfor
tasklist /FI "IMAGENAME eq wmplayer.exe" 2>NUL | find /I /N "wmplayer.exe">NUL
if "%ERRORLEVEL%"=="0" goto :ProgramRunning
if "%ERRORLEVEL%"=="1" goto :ProgramNotRunning
pause
:ProgramRunning
goto testfor
:ProgramNotRunning
shutdown /s /f
最佳答案
当媒体播放停止时,Windows Media Player不支持自动关闭。1而且,它不包含用于控制或读取现有播放器进程状态的任何命令行选项。
至少有四个选项。
vlc://quit
添加到播放列表的末尾。m3u播放列表
#EXTM3U
C:\Path\To\My\Media\File1.mp3
C:\Path\To\My\Media\File2.mp3
vlc://quit
XSPF播放列表
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track><location>file:///C:\Path\To\My\Media\File1.mp3</location></track>
<track><location>file:///C:\Path\To\My\Media\File2.mp3</location></track>
<track><location>vlc://quit</location></track>
</trackList>
</playlist>
使用命令行启动VLC:
start /wait "C:\path\to\vlc.exe" "c:\path\to\playlist\file.m3u"
1 As of 2011官方的官方说法是,这是设计使然。
2欢迎提出请求和错误报告。
关于windows - 检测通过cmd播放的媒体播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38173664/