我试图使用批处理文件以全屏方式简单地打开视频,我意识到这是不可能的,因此我加入了代码来使其写入vbscript,然后再执行vbscript代码。
我正在运行Windows 10,并且还有另一个脚本可以正常运行mp3文件。
这是我的批处理文件正在写入vbscript
set "file2=res\FORTNITESKINS.mp4"
( echo Set wmp = CreateObject("WMPlayer.OCX"^)
echo Video.URL = "%file2%"
echo Video.Controls.play
echo do while Video.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Video.currentmedia.duration^)+1^)*1000
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
这是我执行vbscript的方式
start video.vbs
视频无法打开,只能播放音频,并且wmplayer甚至无法最小化打开,我也无法在任务管理器中找到它。
我也尝试过
set "file2=res\FORTNITESKINS.mp4"
( echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%file2%"^)
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
但是它给出了错误:
Line: 2
Char: 1
Error: 0xC00D1329
Code: C00D1329
Source: (null)
答案 0 :(得分:2)
为什么不直接将Wmplayer与正确的command-line-parameters一起使用?
@Echo off
set "file2=res\FORTNITESKINS.mp4"
set wmplayer="%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe" /prefetch:1
%wmplayer% "%file2%" /fullscreen
答案 1 :(得分:0)
您可以像以下示例一样进行操作:
@echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set "URL-FILE=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8"
Start "%Title%" wmplayer /fullscreen "%URL-FILE%"
Timeout /T 2 /NoBreak>nul
编辑:
@echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set vbs_video=%temp%\vbs_video.vbs
Set video=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8
Call :Play %video%
Timeout /T 2 /NoBreak>nul & Exit
REM ***************************************
:Play <video>
(
echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%~1"^)
echo set WshShell = CreateObject("WScript.Shell"^)
echo WScript.Sleep 3000
echo WshShell.SendKeys "%%{ENTER}"
)>"%vbs_video%"
Start "video" "%vbs_video%"
exit /b
REM ***************************************