中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 搜索 | 上传 | 帮助 »
作者:
标题: DOS/WIN两栖的CD Player 上一主题 | 下一主题
happybasic
中级用户





积分 298
发帖 118
注册 2006-3-1
状态 离线
『第 16 楼』:   使用 LLM 解释/回答一下

前面贴的是主要的一些命令,所以再加一组合就可以完成player的功能了...

/***************************************************************************
name: AudioCDPlayer
return: 0 - sucess
****************************************************************************/
static int AudioCDPlayer(driveinfo *Drive)
{
bool Load=false, Disc=false, Continue=false;
int Temp, Tries, CurrTrack=0, Key;

// Show Help first
ShowHelp();

// Check tray status
Temp=atapiChkTrayIsOpen(Drive);

if (Temp == 0) // Tray is closed
{
// Read Disc TOC
printf("\nTrying to read Audio CD Table-Of-Contents ...\n");

// 5 times max for retry
for(Tries=5; Tries>0; Tries--)
{
Temp=atapiTOC(Drive);
if (Temp == 0 )
{
break;
}
delay(2000);
}

if (Temp == 0) // Disc is Ready
{
Disc=true;
}
else
{
printf("No Disc!");
}
}
else // Tray is opened , can Load
{
Load=true;
}

if(Disc == true ) // 找到碟片,且读Toc OK
{
printf ("Disc is READY\n");
}

while(1)
{
Key=bioskey(0);

if (Key == 0x0000) // Ctrl-Break时强行终止
{
return(0);
}

//****** Esc or Q -> quit ****************
if(Key == 0x011b || Key == 0x1071 || Key == 0x1051)
{
clrscr();
break;
}
//********** e or E -> load/eject ********
else if( Key==0x1265 || Key==0x1245)
{
if(Load)
{
printf ("Please wait for LOAD disc...\n");
}
else
{
printf ("EJECT....\n");
}
atapiEject(Drive, Load);
//Load=!Load;
Load=(Load==true ? false : true);

goto LoadToc;
}
//********** t or T -> load TOC *********
else if(( Key==0x1474 || Key==0x1454) && Load==false)
{

LoadToc:

printf ("WAITING ....\n");

CurrTrack=0; // init variable
NumTracks=0;

for(Tries=5; Tries>0; Tries--)
{
Temp=atapiTOC(Drive);
if (Temp == 0 || Load == true)
{
break;
}
delay(2000);
}

if (Temp != 0)
{
printf ("NO DISC\n");
Disc=false;
}
else
{
printf ("Disc is READY\n");
printf ("Track %d of %d\n", (Temp==0 ? CurrTrack+1 : 0), NumTracks);
Disc=true;
}

}
//********** p or P -> play *************
else if((Key==0x1970 || Key==0x1950) && Disc==true)
{
atapimsf *Start, *End;

Start= Track+CurrTrack;
End= Track+(CurrTrack + 1);

printf ("PLAYING...\n");
printf ("Track %d of %d\n", CurrTrack+1, NumTracks);

atapiPlay(Drive, Start, End);
}
//********** n or N -> play next track **
else if((Key==0x316e || Key==0x314e) && Disc==true)
{
atapimsf *Start, *End;

if(CurrTrack < NumTracks - 1)
{
CurrTrack++;
Start=Track+CurrTrack;
End=Track+(CurrTrack+1);
}

printf ("PLAYING...\n");
printf ("Track %d of %d\n", CurrTrack+1,NumTracks);

atapiPlay(Drive, Start, End);
}
//********** v or V -> play previous trk ****
else if((Key == 0x2f76 || Key == 0x2f56) && Disc==true)
{
atapimsf *Start, *End;

if(CurrTrack > 0)
{
CurrTrack--;
Start=Track+CurrTrack;
End=Track+(CurrTrack+1);
}

printf ("PLAYING...\n");
printf ("Track %d of %d\n", CurrTrack+1,NumTracks);

atapiPlay(Drive, Start, End);
}
//*********** u or U -> pause/continue ****
else if(( Key==0x1675 || Key==0x1655) && Disc==true)
{
if(Continue)
{
printf ("PLAYING...\n");
}
else
{
printf ("PAUSE...\n");
}
atapiPause(Drive, Continue);
//Continue=!Continue;
Continue=(Continue==true ? false : true);
}
//*********** s or S -> stop play/scan ***
else if((Key==0x1f73 || Key==0x1f53) && Disc==true)
{
printf ("STOP...\n");
atapiStop(Drive);
}
}
return(0);
}

呵呵,这个CDPLAY播放器其实就是这么简单的..




欢迎光临happyBASIC小站:http://yxbasic.51.net
2009-3-13 11:04
查看资料  发送邮件  发短消息  网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: