VOGONS


First post, by ElBrunzy

User metadata
Rank Oldbie
Rank
Oldbie

Hi, I think my question need a bit of context first. I enjoy using some music players under dos since they bring all kind of niceties that is sometimes lost under windows. We cannot reproach those authors not to have included a playlist support as it is easier said than done. So those who made batch file playlist might get a hint at where I am going at. What is the best way to exit that batch in between each program call.

Let say we use Gravis playmidi to illustrate the problem, I think that player even load patches before it check to skip the music, so people would ctrl-alt-del in despair to exit such playlist.
playlist.bat content:

C:\ultrasnd\playmidi.exe C:\midi\music1.mid -video
CALL checkKeyPress
C:\ultrasnd\playmidi.exe C:\midi\music2.mid -video
CALL checkKeyPress
C:\ultrasnd\playmidi.exe C:\midi\music3.mid -video
CALL checkKeyPress
C:\ultrasnd\playmidi.exe C:\midi\music4.mid -video
goto :EOF
:checkKeyPress
CHOICE /C YN /M "exit playlist Y/n?" /D N /T 1
IF %ERRORLEVEL% EQU 1 goto:EOF
exit /B

I've drafted this with no testing, it probably wont work but it's to illustrate what I have in mind. What bother's me the most here is that I would like not to introduce a 1 second pause in between two song and just scan if a key is pressed and abort the playlist batch in that case. From the doc, "/T 0" on CHOICE would only select default choice. I would prefer to avoid calling a third party program to handle keypress. Do not forget that it is for command.com and most niceties from cmd.exe are not present, that being said, I am very bad a command.com batch files so it is possible I miss something very obvious and I would appreciate any input. I think hammering ctrl-c/break do not work so well in that case also it remove the opportunity to end the batch and get back the the playlist editor that way.

Thanks for your time, I'm eager to read your suggestions.

Reply 1 of 2, by K1n9_Duk3

User metadata
Rank Member
Rank
Member

The player program itself might actually return different ERRORLEVEL codes based on what caused it to quit to DOS. If it does, you could insert something like "IF %ERRORLEVEL% (whatever) GOTO end" after each line that starts the player.

If it doesn't, but you know which key is used to abort playback (ESC for example), you could just write yourself a small utility that reads the keyboard port and checks if the last scan code was a make or break code for that key. That utility could then return different error codes based on which scancode it read and the batch file could process those.

Reply 2 of 2, by ElBrunzy

User metadata
Rank Oldbie
Rank
Oldbie

I was afraid I had no choice to rely on a small utility to read the keyboard in an non intrusive way, but I did not figured the utility could talk back to the calling batch file using error level. That limit the overhead of this avenue to an acceptable level, thanks K1n9_Duk3, I will experiment the idea.