本文共 15296 字,大约阅读时间需要 50 分钟。
由于百度不支持显示部分代码,可能无法正常显示,拷贝完整代码请到下面地址:
批处理版音视频播放器V6.7 歌词版:
代码拷贝:(主要更新位置与最新版本)
直接下载:
BatMPlayerV7.4:
文件名称:上传用户:文件大小:12.48KB文件格式:rar下载次数:0上传时间:2010-11-29 17:34:12上 传 IP:113.12.*.*文件MD5:22EB9C97F5BBE686810F4ED238E7D268
以下是旧版本的代码,由于代码有点长,分为上下两篇,这里是上篇,下篇在:
将上下两篇的代码复制到新建记事本中,另存为“批处理版音视频播放器.bat”或“BatMPlayer V5.3.bat”,注意后缀名为【.bat】,双击运行即可。
@echo off&setlocal enabledelayedexpansion
title BatMPlayer V5.3 歌词版 ::by cjiabing;from ::date:2010.10.10;cmd@xp COLOR 2E set input=%* if not exist %SYSTEMROOT%\sleep.exe set "var_sleep=%~0" call :beforehand_default :beforehand_drag rem 拖拉输入 if not exist !mpp! (call :beforehand_findmplayer) else ( if defined input ( if exist "%~dp0_playlists.txt" del "%~dp0_playlists.txt" for /f "tokens=*" %%a in ("!input!") do ( for %%i in (%%a) do ( if exist %%i set input=%%~i if /i "!input:~-4,4!"==".txt" ( type "!input!">>"%~dp0_playlists.txt" goto play_txt ) if exist "!input!\." dir /a:d "!input!"&&set input=!input!&&goto inport_folder echo !input!>>"%~dp0_playlists.txt" ))
goto play_txt ) ):start
rem 主界面 set "a=a" call :main_face call :backgroundmusic :main set "a=b" call :main_face call :input :main_face cls echo. if /i "%a%"=="a" ( call :colour "27" "∷∷∷∷I'M LOOKING OUT,I'M LOOKING IN. WAY DOWN,THE LIGHTS ARE DIMMER∷∷∷∷" ) else ( call :colour "27" "∷∷∷∷批处理,她就像中国围棋,小棋盘大世界,虽然简单但同样能带给你精彩∷∷∷∷" ) call :colour "27" "∷∷∷∷"&call :colour "2f" " 设置【S】搜索【F】帮助【H】热键【HK】退出【Q】CMD【C】BAT【B】"&call :colour "27" "∷∷∷∷" echo. echo. echo. call :colour "2b" " ◥██▃▁ _ _..-‐‐-." echo. call :colour "2b" " ...◥████▅▄▃▁▁▁▁▁▃▄▅▅▆▇▇▅▄▃▃▃▃▃▅▄▁" echo.^ &call :colour "2b" " ≡¤███"&call :colour "0c" "━批处理版音★视频播放器━"&call :colour "2b" "██████████████▅▄▃▁▁" echo. call :colour "2b" " ≡¤███████████████████◤" echo. echo. echo. goto :eof:input
rem 输入汇总 call :keyin goto main :keyin set /p "input= %~pds0" if /i !input!=="" goto start if not defined input if exist "%~dp0_playlists.txt" (goto play_txt) else (goto start) call :inport call :input_sets call :input_end goto :eof :inport for /f "tokens=*" %%a in ("!input!") do set "input=%%~a" if exist "!input!" ( if /I "!input:~-4,4!"==".txt" call :inport_txt if /I "!input:~-5,4!"==".txt" call :inport_txt if exist "!input!\" goto inport_folder dir /a:d !input!||call :play_file&goto main :inport_folder if /i not "!input:~-1,1!"=="\" (set "input=!input!\") else (set "input=!input!") cd.>"%~dp0_playlists.txt" dir /a-d /b /s "!input!*.wma" "!input!*.mp3">>"%~dp0_playlists.txt" goto play_txt ) for %%a in (http rtsp vcd dvd) do if /i "!input:~0,4!"=="%%a" ( echo !input!>"%~dp0_playlists.txt" type "%USERPROFILE%\My Documents\My Music\_urlplaylists.txt">>"%~dp0_playlists.txt" del /q "%USERPROFILE%\My Documents\My Music\_urlplaylists.txt">nul copy "%~dp0_playlists.txt" "%USERPROFILE%\My Documents\My Music\_urlplaylists.txt">nul 2>nul echo !input!>"%~dp0_playlists.txt" call :play_txt ) goto :eof :input_end call :input_sets echo. CMD /C !input!&echo.&pause&cls goto main:input_sets
rem 全局快捷键 if /i "!input!"=="S" goto setting if /i "!input!"=="F" call :search&goto main if /i "!input!"=="C" call :cl&goto main if /i "!input!"=="B" call :bc&goto main if /i "!input!"=="H" goto help IF /I "!input!"=="RS" goto play_general IF /I "!input!"=="GC" goto play_general if /i "!input!"=="HK" call :entry&goto main if /i "!input!"=="OP" call :play_sets&goto main if /i "!input!"=="BM" goto start IF /I "!input!"=="CB" START "" IEXPLORE.EXE MAIN IF /I "!input!"=="BH" START "" IEXPLORE.EXE MAIN IF /I "!input!"=="CD" START "" MAIN IF /I "!input!"=="MP" START "" IEXPLORE.EXE MAIN if /i "!input:~0,2!"=="SD" call :tasks_shut&goto main if /i "!input!"=="Q" exit :websearch for /f "tokens=1,2,* delims= " %%i in ("!input!") do ( if /i "%%i"=="bd" start "" IEXPLORE.EXE "search if /i "%%i"=="gg" start "" IEXPLORE.EXE "search if /i "%%i"=="sg" start "" IEXPLORE.EXE "search if /i "%%i"=="kg" start "" IEXPLORE.EXE "search if /i "%%i"=="gou" start "" IEXPLORE.EXE "search if /i "%%i"=="ss" start "" IEXPLORE.EXE "search ) goto :eof :inport_txt if exist "%~dp0_playlists.txt" ( if "!input!"==""%~dp0_playlists.txt"" ( goto play_txt ) else ( cd.>"%~dp0_playlists.txt" type "!input!">>"%~dp0_playlists.txt" goto play_txt ) ) else ( cd.>"%~dp0_playlists.txt" type "!input!">>"%~dp0_playlists.txt" goto play_txt ) goto :eof:tasks_shut
for /f "tokens=1,2,* delims= " %%i in ("!input!") do ( if /i "%%i"=="sd" ( if "%%j"=="" call :colour "0c" " 查询设置!"&echo.&cmd /c "at&exit /b"&echo.&pause&goto :eof if /i "%%j"=="c" ( echo. if not "%%k"=="" ( at %%k shutdown -a>nul 2>nul call :colour "0c" " 已经取消自动关机!原计划关机时间为:"&echo,%%k call :colour "0c" " 取消自动关机时间最好比原计划关机时间推迟1分钟:"&echo, ) else ( shutdown -a>nul 2>nul call :colour "0c" " 已经取消当前正在进行中的自动关机!"&echo. ) ping /n 5 127.0.1>nul&goto :eof ) if /i "%%j"=="stop" sc stop schedule&ping /n 3 127.0.1>nul&goto :eof if /i "%%j"=="start" ( sc start schedule sc config schedule start= auto ping /n 3 127.0.1>nul&goto :eof ) if /i "%%j"=="at" call :colour "0c" " 查询设置!"&echo.&cmd /c "at&exit /b" &echo.&pause&goto :eof echo. at %%j shutdown -s -f -t 128>nul 2>nul&&call :colour "0c" " 设置完成,自动关机时间为:"&echo, %%j&ping /n 5 127.0.1>nul&goto :eof ) if /i "%%i"=="at" call :colour "0c" " 查询设置!"&echo.&cmd /c "at&exit /b"&echo.&pause&goto :eof ) ping /n 3 127.0.1>nul&goto :eof:play
rem 播放程序 COLOR 2E if not defined mpp goto beforehand_default cls echo.=========================================================================== call :colour "0c" "★★★正在播放!下一首【PageUp】快进【Up】静音【M】暂停【P】退出【Q】★★★"&echo. echo.=========================================================================== goto :eof :play_txt call :play !mpp! -playlist "%~dp0_playlists.txt" for /f "tokens=2" %%a in ('tasklist /fi "WINDOWTITLE eq BatMPlayerMiniLyrics" /FO TABLE /NH') do taskkill /pid %%a>nul 2>nul goto main :play_file if /i "!input!"=="LRC" del /q /f %SYSTEMROOT%\Lyrics.bat,%SYSTEMROOT%\sleep.exe if not exist %SYSTEMROOT%\sleep.exe ( echo. echo. call :colour "0c" " 第一次运行歌词显示,需要初始化!" echo. call :colour "0c" " 初始化之后如无法正常使用请关闭本程序重新打开!" echo. echo. pause if not exist %SYSTEMROOT%\Lyrics.bat call :Lyrics goto sleep ) else ( if not exist %SYSTEMROOT%\Lyrics.bat (call :Lyrics) else ( if "!input:~-5,4!"==".mp3" start "" %SYSTEMROOT%\Lyrics.bat if "!input:~-4,4!"==".mp3" start "" %SYSTEMROOT%\Lyrics.bat if "!input:~-5,4!"==".wma" start "" %SYSTEMROOT%\Lyrics.bat if "!input:~-4,4!"==".wma" start "" %SYSTEMROOT%\Lyrics.bat ) ) call :play !mpp! "!input!" for /f "tokens=2" %%a in ('tasklist /fi "WINDOWTITLE eq BatMPlayerMiniLyrics" /FO TABLE /NH') do taskkill /pid %%a>nul 2>nul goto :eof :play_general if exist "%~dp0_playlists.txt" ( IF /I "!input!"=="gc" ( for /f "usebackq tokens=*" %%a in ("%~dp0_playlists.txt") do if exist "%%~a" set "input=%%~a"&&call :play_file goto main ) IF /I "!input!"=="r" set "pp=-loop 0 -playlist"&set input="%~dp0_playlists.txt" IF /I "!input!"=="s" set "pp=-shuffle -playlist"&set input="%~dp0_playlists.txt" IF /I "!input!"=="rs" set "pp=-shuffle -loop 3 -playlist"&set input="%~dp0_playlists.txt" call :play !mpp! !pp! "%~dp0_playlists.txt" ) ::IF defined pp ("!mpp!" !pp! !input!) else ("!mpp!" !input!) goto main goto :eof:beforehand_default
rem 默认播放器路径 if exist "%ProgramFiles%\StormII\codec\MPlayer.exe" ( set mpp="%ProgramFiles%\StormII\codec\MPlayer.exe" if not exist %SYSTEMROOT%\MPlayerPath.ini echo mppt=!mpp!>%SYSTEMROOT%\MPlayerPath.ini ) else ( if exist %SYSTEMROOT%\MPlayerPath.ini (goto beforehand_mplayerpath) else (call :beforehand_findmplayer) ) goto :eof:beforehand_mplayerpath
if exist %SYSTEMROOT%\MPlayerPath.ini ( set "var_bmp=" for /f "tokens=1,* delims== " %%i in (%SYSTEMROOT%\MPlayerPath.ini) do ( if /i not "%%i"=="" if /i "%%i"=="mppt" set var_bmp=a&set "mpp=%%~j" ) if not defined var_bmp (call :beforehand_findmplayer&goto beforehand_mplayerpath) else ( if exist !mpp! (goto beforehand_drag) else (call :beforehand_findmplayer&goto beforehand_mplayerpath) ) ) goto :eof:backgroundmusic
rem 背景音乐 if not defined mpp ( call :beforehand_mplayerpath if defined mpp (goto backgroundmusic) else ( set var_start= 对不起!播放器不存在!请安装设置! goto :beforehand_findmplayer ) ) else ( if exist !mpp! ( call :colour "27" " 背景音乐播放中,停止播放请按【Q】或【EnTer】" if exist "%USERPROFILE%\My Documents\My Music\_urlplaylists.txt" ( !mpp! -playlist "%USERPROFILE%\My Documents\My Music\_urlplaylists.txt">nul 2>nul||!mpp! -cache 20482>nul&goto main ) else ( !mpp! -cache 20482>nul&goto :eof ) ) else ( set var_start= 对不起!播放器不存在!请安装设置!) call :beforehand_findmplayer ) goto :eof:setting
cls COLOR 27 echo. call :colour "2E" " 设置选项"&echo. echo. __________________________________________________________________________ echo. call :colour "2F" " ★ 播放列表" &echo →搜索与创建【F】; echo →将媒体文件拖至“程序图标”上自动生成播放列表; call :colour "2F" " ★ 循环模式" &echo →随机【S】\重复【R】\随机并重复【RS】; echo →需先设置播放列表;只对当前播放有效;全局通用键【RS】; call :colour "2F" " ★ 播放器参数设置" &echo →使用介绍【OP】; call :colour "2F" " ★ 歌词设置" &echo →安装【LRC】;路径设置【P】歌词模式【GC】 echo →窗口单曲播放显示歌词;歌词模式需先设置播放列表; echo →MP3歌名最佳形式:歌手名 + 歌曲名;如:许巍 - 完美生活 call :colour "2F" " ★ MPlayer程序路径设置" &echo →设置【P】; call :colour "2F" " ★ 自动关机设置" &echo →查看【At/sd】新建关机计划【SD time】如:sd 23:15 echo →取消【SD C / SD C time(最好延后一分钟)】如:sd c 23:16 echo →须开服务【SD Start】停止服务【SD Stop】; call :colour "2F" " ★ 编写批处理" &echo →进入【B】; echo. echo. __________________________________________________________________________ echo. call :colour "2E" " 请选择(返回【Q】):" set /p input= IF /I "!input!"=="" goto setting IF /I "!input!"=="rs" goto play_general IF /I "!input!"=="r" goto play_general IF /I "!input!"=="s" goto play_general if /i "!input!"=="LRC" call :play_file&goto setting IF /I "!input!"=="p" goto way IF /I "!input!"=="OP" goto play_sets IF /I "!input!"=="q" goto main call :input_sets echo. pause goto main:way cls COLOR 27 echo. call :colour "2E" " 路径设置"&echo. echo. __________________________________________________________________________ echo. echo. echo 当前 MPlayer.exe 的路径是: echo. if exist !mpp! (echo, !mpp!) else (echo 为空!) echo. echo. MPlayer路径设置:【Mppt=MPlayer路径】搜索【F】默认【MR】返回【Q】 echo. 歌词路径设置:【Lyrc=歌词路径】如:lyric=C:\Lyrics echo. call :colour "2E" " 请按格式要求输入路径:" set /p input= IF /I "!input!"=="" goto way if /i "%input%"=="q" goto setting if /i "%input%"=="mr" goto way_default call :input_sets if /i "%input:~0,4%"=="lyrc" echo lyrc=%input%>>%SYSTEMROOT%\MPlayerPath.ini if /i "%input:~0,4%"=="mppt" echo mppt=%input%>>%SYSTEMROOT%\MPlayerPath.ini&set "mpp=!input!" :way_default if /i "%input%"=="mr" ( if exist %ProgramFiles%\StormII\codec\MPlayer.exe ( echo mppt=%ProgramFiles%\StormII\codec\MPlayer.exe>>%SYSTEMROOT%\MPlayerPath.ini set mpp="%ProgramFiles%\StormII\codec\MPlayer.exe" echo. echo ★ 设置完成!MPlayer的路径为:!mpp! ) else (echo ★ 默认路径不存在!请检查!) ) else ( echo. echo ★ 设置完成!新设的路径为:!input! ) echo. pause goto setting
:beforehand_findmplayer
cls COLOR 27 echo. call :colour "2E" " 缺少MPlayer.exe文件,无法播放,正在搜索……"&echo. echo. __________________________________________________________________________ echo. echo ★ 尝试搜索常用安装目录,请稍候…… echo. for %%a in ("%ProgramFiles%\StormII\codec\MPlayer.exe" "D:\Program Files\StormII\codec\mplayer.exe" "D:\mplayer\mplayer.exe" "C:\mplayer\mplayer.exe" "C:\MPlayer_Windows\mplayer.exe" "D:\Program Files\Super Player\codecs\MPlayer.exe" "%ProgramFiles%\Super Player\codecs\MPlayer.exe") do if exist %%a set mpp=%%a&&echo mppt=!mpp!>>%SYSTEMROOT%\MPlayerPath.ini&&goto startecho.
echo ★ 尝试搜索C、D盘,请稍候…… echo. cd.>%SYSTEMROOT%\MPlayerPath.ini for %%a in (C D) do if exist %%a:\ cd /d %%a:\ && for /r %%i in (MPlayer.exe) do if exist %%i ( echo mppt=%%i>>%SYSTEMROOT%\MPlayerPath.ini set "mpp=%%i" goto start ) echo. call :colour "2C" " ★ 无法找到MPlayer.exe文件!您将无法正常使用本程序!"&echo. call :colour "2C" " ★ 请确认您的系统安装有MPlayer并手动设置MPlayer.exe的路径。"&echo. call :colour "2C" " ★ 建议从MPlayer官方网站下载安装MPlayer播放器程序!"&echo. echo. call :colour "2C" " ★ 正在自动返回!……"&echo. echo. ping /n 15 127.0.1>nul start "" IEXPLORE.EXE goto main:search
cls COLOR 27 echo. call :colour "2E" " 查找音视频文件并生成播放列表"&echo. echo. __________________________________________________________________________ echo. call :colour "2F" " ★ 路径名(全盘【A】):" &echo 有空格需引号。如: echo F:\ "D:\Program Files\easy" call :colour "2F" " ★ 搜索词:" &echo 多个搜索词之间用空格隔开,如: echo 雅尼 陈慧娴 边走边爱 call :colour "2F" " ★ 网页搜索:" &echo 格式:网站名缩写 + 搜索词,如: echo 谷歌搜索“刘德华”:GG 刘德华; echo 搜狗搜索“情难自禁”:SG 情难自禁 echo 百度【BD】谷歌【GG】狗狗【Gou】酷狗【KG】搜狗【SG】搜搜【SS】; call :colour "2F" " ★ 常见音频格式【Y】:" &echo *.mp3 *.wma *.wav。 call :colour "2F" " ★ 常见视频格式【S】:" &echo *.mp4 *.flv *.3gp *.mpg *.avi *.wmv *.rm *.rmvb call :colour "2F" " ★ 技巧:" &echo 可直接将媒体文件拖拉至程序图标上,程序自动生成播放列表。 call :colour "2F" " ★ 返回【Q】" &echo. echo. __________________________________________________________________________ echo. call :colour "2E" " 输入路径名:" set /p "input=" IF /I "!input!"=="" goto search if not defined input set "input=%~d0" if /i "!input:~-1,1!"=="\" (set input="!input:~0,-1!") else (set input=!input!) IF /I "!input!"=="q" goto :eof call :input_sets call :colour "2E" " 输入搜索词:" set /p "inport=" IF /I "!input!"=="" goto search if not defined inport set "inport=*.mp3" IF /I "!input!"=="a" goto search_all if /i "!inport!"=="q" goto main if exist "%~dp0_playlists.txt" del /q "%~dp0_playlists.txt">nul 2>nul if /i "!inport!"=="y" dir /a-d /b /s !input!\*.wma !input!\*.mp3>>"%~dp0_playlists.txt"&goto search_end if /i "!inport!"=="s" dir /a-d /b /s !input!\*.avi !input!\*.wm !input!\*.rm !input!\*.rmvb !input!\*.wmv !input!\*.mpg !input!\*.flv !input!\*.3gp !input!\*.mp4>>"%~dp0_playlists.txt"&goto search_end for %%i in (%inport%) do ( set "var_ser=%%i" if /i "!var_ser:~-3,1!"=="." dir /a-d /b /s %input%\!var_ser! if /i "!var_ser:~-4,1!"=="." dir /a-d /b /s %input%\!var_ser! if /i "!var_ser:~-5,1!"=="." (dir /a-d /b /s %input%\!var_ser!) else (dir /a-d /b /s %input%\*%%i*.*) )>>"%~dp0_playlists.txt" :search_end echo. if exist "%~dp0_playlists.txt" type "%~dp0_playlists.txt" echo. if exist "%~dp0_playlists.txt" (call :colour "2E" " ★ 搜索完毕!已在当前目录生成文件列表_playlists.txt。"&echo.) else (call :colour "2E" " ★ 搜索失败,请重试!"&echo.&echo.&pause&goto search) echo. pause goto :eof :search_all cls echo. echo ★ 正在全盘搜索,请稍候…… echo. if exist "%~dp0_playlists.txt" cd.>"%~dp0_playlists.txt" for %%x in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do ( if /i "%inport%"=="y" if exist %%x (dir /a-d /b /s "%%x\*.mp3" "%%x\*.wma">>"%~dp0_playlists.txt") else (goto search_end) if /i "%inport%"=="s" ( if exist %%x ( dir /a-d /b /s "%%x\*.avi" "%%x\*.wm" "%%x\*.rm" "%%x\*.rmvb" "%%x\*.wmv" "%%x\*.mpg" "%%x\*.flv" "%%x\*.3gp" "%%x\*.mp4">>"%~dp0_playlists.txt" ) else (goto search_end) ) else ( if /i not "%inport%"=="y" ( if exist %%x ( for %%i in (%inport%) do ( set "var_ser=%%i" if /i "!var_ser:~-3,1!"=="." dir /a-d /b /s "%%x\!var_ser!" if /i "!var_ser:~-4,1!"=="." dir /a-d /b /s "%%x\!var_ser!" if /i "!var_ser:~-5,1!"=="." (dir /a-d /b /s "%%x\!var_ser!") else (dir /a-d /b /s "%%x\*%%i*.*") )>>"%~dp0_playlists.txt" ) ) ) ) goto search_end:colour pushd "%temp%" >"%~2",set/p= <nul findstr /a:%~1 .* "%~2*" del "%~2" popd goto :eof
:CL
cls COLOR 27 echo. call :colour "2E" " ★ 你已进入命令行提示符!退出【EXIT】;批处理编辑器【B】。 ★"&echo. echo. __________________________________________________________________________ echo.&set /p input=%~pds0 if /I "!input!"=="B" goto bc if /I "!input!"=="exit" goto main call :input_sets CMD /k !input! goto :eof
本篇为原创,转载请注明出处。甲兵时代,为你服务。