| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Sample program for CD2 unit |
Hello All!
Using this player is quite simple,
If you do not enter any command line option, a simple help screen will popup
p -> play whole cd
p first_track -> play whole cd beginning with first_track
p first_track last_track -> play whole cd beginning with first_track
ending with last_track
P track_to_play -> plays only track_to_play
w -> watch current location of head
t -> show number of tracks
e -> eject disk
s -> stop playing
r -> resume playing where drive stopped playing after
receiving 'stop playing' command
=== Begin play2.pas ===
PROGRAM sample_player;
{$X+}
USES cd2, os2def, os2base, use32, crt;
CONST
play : Boolean = False;
{ play track }
watch : Boolean = False;
{ watch cd }
stop : Boolean = False;
{ stop drive }
resume : Boolean = False;
{ resume playing }
tracks : Boolean = False;
{ view tracks }
one_track : Boolean = False;
{ play only one track }
eject : Boolean = False;
{ eject disk }
VAR
device_handle : hfile;
play_from,
play_to : Byte;
result : Integer;
{ for val conversion }
temporary : String[10];
begin_end : cd_struct;
track_size : track_start_stop;
{ begin and end of a track }
head_location : current_position;
{ needed for watch param }
PROCEDURE check_command_line;
BEGIN
temporary := ParamStr(1);
IF temporary = 't' THEN
{show tracks }
BEGIN
tracks := True;
Exit;
END;
IF temporary = 'p' THEN
{ play all tracks from }
BEGIN
play := True;
IF ParamCount < 2 THEN play_from := first_track
ELSE
BEGIN
Val(ParamStr(2), play_from, result);
{ first track to play }
IF result 0 THEN
BEGIN
WriteLn('Wrong track');
Halt;
END;
END;
IF ParamCount < 3 THEN play_to := last_track
ELSE
BEGIN
Val(ParamStr(3), play_to, result);
IF result 0 THEN
BEGIN
WriteLn('Wrong track');
Halt;
END;
END;
Exit;
END;
IF temporary = 'P' THEN
{ play one track }
BEGIN
play := True;
Val(ParamStr(2), play_from, result);
IF result 0 THEN
BEGIN
WriteLn('Wrong track');
Halt;
END;
one_track := True;
Exit;
END;
IF temporary = 's' THEN
{ stop playing }
BEGIN
stop := True;
Exit;
END;
IF temporary = 'w' THEN
{ watch }
BEGIN
watch := True;
Exit;
END;
IF temporary = 'r' THEN
{ resume playing }
BEGIN
resume := True;
Exit;
END;
IF temporary = 'e' THEN
{ eject }
BEGIN
eject := True;
Exit;
END;
END;
BEGIN
WriteLn;
WriteLn('Simple CD player 1.00');
WriteLn;
IF ParamStr(1) = '' THEN
BEGIN
{ start writing help if no params are entered }
WriteLn('By Gerard Gerritsen ');
WriteLn('based on the unit CD2');
WriteLn;
WriteLn(' s -> Stop playing ');
WriteLn(' t -> Show all tracks ');
WriteLn(' p -> Play a track until the end of the cd');
WriteLn(' P -> Play only ONE track ');
WriteLn(' w -> Watch drive playing ');
WriteLn(' e -> Eject disk ');
WriteLn(' r -> Resume playing');
WriteLn;
Halt;
END;
IF init_cdrom(device_handle, track_pointer)
THEN
BEGIN
check_command_line;
IF stop THEN stop_playing(device_handle);
IF resume THEN resume_playing(device_handle);
IF eject THEN open_tray(device_handle);
IF watch THEN
BEGIN
clrscr;
WriteLn('Press any key to stop watching');
WriteLn;
REPEAT
get_current_location(device_handle, head_location);
gotoxy(1, 3);
WriteLn('Current position is ', head_location.current.minutes:2, ':',
head_location.current.seconds:2, '.',
head_location.current.frames:2);
dossleep(1000);
{sleep for one second }
UNTIL keypressed;
END;
IF tracks THEN
BEGIN
WriteLn(' There are ', last_track-first_track+1, ' tracks');
WriteLn(' Beginning from track ', first_track,
' to track ', last_track);
Halt;
END;
IF play THEN
IF first_track = 0 THEN
BEGIN
WriteLn('There is no audio disc in the drive');
Halt;
END
ELSE
BEGIN
IF play_from < first_track THEN play_from := first_track;
Write('Playing track ', play_from);
IF one_track THEN play_to := play_from ELSE
BEGIN
IF play_to > last_track THEN play_to := last_track;
track_pointer^[play_from].stop := track_pointer^[play_to].stop;
WriteLn(' to ', play_to);
END;
WriteLn;
{ if do not play until the end of the CD }
IF NOT Play_track(device_handle, track_pointer^[play_from])
THEN
WriteLn('The drive is probably playing a cd right now');
END;
close_cdrom(device_handle);
END
ELSE WriteLn('I cannot open the cdrom device driver, I''m sorry ');
END.
=== End play2.pas ===
==> Gerard/2 - member of team os/2 - 1000521{at}ibk.fnt.hvu.nl
--- Fmail/2 1.02 Registered
* Origin: Yet another forgotten area! (2:283/203.18)SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 283/203 2 6 1 512 280/801 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.