資源簡介
本人大三課程設計,要求在linux系統下,利用madplay插件使用c語言進行編程,在終端內實現音樂播放器的功能。
代碼片段和文件信息
/*
?*?文件名:madplay.c
?*?頭文件:madplay.h
?*?說明:實現madplay的控制,包括播放play、暫停suspend、開始start、下一首next、上一首previous
?*?作者:張開
?*?日期:2017.5.13
?*/
#include?
#include?
#include?
#include?
#include?
#include?“madplay.h“
#ifdef?MADPLAY_DEBUG
int?main()
{
????pid_t?pid;
????char?*name?=?“./music/happy.mp3“;
????pid?=?play(name);
????printf(“child?pid:?%d\n“?pid);
????char?con;
????printf(“suspend?“);
????scanf(“%c“?&con);
????getchar();
????printf(“\n“);
????if(‘y‘?==?con)
????????suspend(pid);
???
????printf(“continue?“);
????scanf(“%c“?&con);
????getchar();
????if(‘y‘?==?con)
?????????continuePlay(pid);
????printf(“end?“);
????scanf(“%c“?&con);
????printf(“\n“);
????end(pid);
????return?0;
}
#endif
/*?成功則返回進程pid,失敗則返回0?*/
int?play(char?*name)
{
????pid_t?pid;
????int?status;
????if((pid?=?fork())?0)
????{
????????perror(“Fork?error\n“);
????????return?0;
????}
????else?if(0?==?pid)
????{
????????waitpid(getppid()?&status?0);?//?等待父進程結束
????????execlp(“madplay“?“madplay““-q“?name?(char*)0);
????????return?0;
????}
????else
????{
????????return?pid;????
????}
}
int?suspend(pid_t?pid)
{
????kill(pid?SIGSTOP);
????return?0;
}
int?continuePlay(pid_t?pid)
{
????kill(pid?SIGCONT);
????return?0;
}
int?end(pid_t?pid)
{
????kill(pid?SIGINT);
????return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.???????430??2017-06-19?16:54??MP3-Pla
????..A..H.????????41??2017-06-19?16:54??MP3-Pla
?????文件???????1456??2017-06-19?16:54??MP3-Pla
?????文件????????239??2017-06-19?16:54??MP3-Pla
?????文件???????2376??2020-12-24?19:39??MP3-Pla
?????文件???????7960??2020-12-25?01:05??MP3-Pla
?????文件???????7960??2020-12-25?00:06??MP3-Pla
?????文件??????10776??2020-12-25?01:05??MP3-Pla
?????文件????????383??2017-06-19?16:54??MP3-Pla
?????文件??????18729??2020-12-25?01:05??MP3-Pla
?????文件?????876534??2020-12-22?15:52??MP3-Pla
?????文件?????282992??2017-06-19?16:54??MP3-Pla
?????文件?????478522??2017-06-19?16:54??MP3-Pla
?????文件????4001181??2020-12-25?00:29??MP3-Pla
?????文件????1391860??2017-06-19?16:54??MP3-Pla
?????文件???13411309??2020-12-25?00:27??MP3-Pla
?????文件?????512660??2017-06-19?16:54??MP3-Pla
?????文件?????488164??2017-06-19?16:54??MP3-Pla
?????文件?????411307??2017-06-19?16:54??MP3-Pla
?????文件?????279370??2020-12-25?00:14??MP3-Pla
?????文件????3196969??2020-12-24?19:45??MP3-Pla
?????文件???????3828??2017-06-19?16:54??MP3-Pla
?????文件????????696??2017-06-19?16:54??MP3-Pla
?????文件???????3368??2020-12-24?19:39??MP3-Pla
?????文件???????2048??2017-06-19?16:54??MP3-Pla
?????文件????????225??2017-06-19?16:54??MP3-Pla
?????文件???????2144??2020-12-24?19:39??MP3-Pla
?????文件???????1705??2017-06-19?16:54??MP3-Pla
?????目錄??????????0??2020-12-25?22:30??MP3-Pla
?????目錄??????????0??2020-12-25?22:30??MP3-Pla
............此處省略3個文件信息
評論
共有 條評論