• 大小: 23.97MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-15
  • 语言: C/C++
  • 标签: madplay  linux  

资源简介

本人大三课程设计,要求在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-Player-with-Madplay-master\.gitignore

    ..A..H.        41  2017-06-19 16:54  MP3-Player-with-Madplay-master\.music_config

     文件       1456  2017-06-19 16:54  MP3-Player-with-Madplay-master\madplay.c

     文件        239  2017-06-19 16:54  MP3-Player-with-Madplay-master\madplay.h

     文件       2376  2020-12-24 19:39  MP3-Player-with-Madplay-master\madplay.o

     文件       7960  2020-12-25 01:05  MP3-Player-with-Madplay-master\main.c

     文件       7960  2020-12-25 00:06  MP3-Player-with-Madplay-master\main.c~

     文件      10776  2020-12-25 01:05  MP3-Player-with-Madplay-master\main.o

     文件        383  2017-06-19 16:54  MP3-Player-with-Madplay-master\makefile

     文件      18729  2020-12-25 01:05  MP3-Player-with-Madplay-master\mp3player

     文件     876534  2020-12-22 15:52  MP3-Player-with-Madplay-master\music\1.mp3

     文件     282992  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\apple.mp3

     文件     478522  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\bigbang.mp3

     文件    4001181  2020-12-25 00:29  MP3-Player-with-Madplay-master\music\huohongdesarilang.mp3

     文件    1391860  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\Merry.mp3

     文件   13411309  2020-12-25 00:27  MP3-Player-with-Madplay-master\music\pipaxing.mp3

     文件     512660  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\super.mp3

     文件     488164  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\Super2.mp3

     文件     411307  2017-06-19 16:54  MP3-Player-with-Madplay-master\music\tankBGM.mp3

     文件     279370  2020-12-25 00:14  MP3-Player-with-Madplay-master\music\zhexian.mp3

     文件    3196969  2020-12-24 19:45  MP3-Player-with-Madplay-master\music\开学第一课.mp3

     文件       3828  2017-06-19 16:54  MP3-Player-with-Madplay-master\music_list.c

     文件        696  2017-06-19 16:54  MP3-Player-with-Madplay-master\music_list.h

     文件       3368  2020-12-24 19:39  MP3-Player-with-Madplay-master\music_list.o

     文件       2048  2017-06-19 16:54  MP3-Player-with-Madplay-master\readFileList.c

     文件        225  2017-06-19 16:54  MP3-Player-with-Madplay-master\readFileList.h

     文件       2144  2020-12-24 19:39  MP3-Player-with-Madplay-master\readFileList.o

     文件       1705  2017-06-19 16:54  MP3-Player-with-Madplay-master\README.md

     目录          0  2020-12-25 22:30  MP3-Player-with-Madplay-master\music

     目录          0  2020-12-25 22:30  MP3-Player-with-Madplay-master

............此处省略3个文件信息

评论

共有 条评论