1,播放音乐需要的资源
(1)音乐文件 (.mp3, .wav … )
(2)Linux下音乐解码器 (madplay:开发板上默认移植好了,可以直接用)
2,madplay播放器使用
(1)登录到开发板系统
(2)查看madplay播放器的位置 --> which madplay : /usr/bin/madplay
(3)使用madplay播放音乐(自己准备音乐文件 xx.mp3)
==> 将mp3文件烧写到开发板
==> U盘拷贝文件到当前路径
A,把需要拷贝的音乐文件放在 U盘下的music文件夹下
B,把U盘接入开发板
C, 把U盘的music文件夹下的所有mp3文件拷贝到当前工作路径
==> cp /mnt/udisk/music/*.mp3 ./
D, 使用madplay播放器播放一首音乐
==> 使用命令播放: madplay xxx.mp3
请添加图片描述
==》例子:多进程编程控制音乐播放
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <linux/input.h> //输入子系统的头文件
#include <sys/mman.h>
#define TS_PATH "/dev/input/event0"
#define LCD_PATH "/dev/fb0"
int lcd_fd;
int *FB;
int ts_x, ts_y; //存放点击屏幕的横纵坐标
char music_path[3][32] = {
"faded.mp3", "dy.mp3", "yy.mp3"};
/*获取一次点击触摸屏的坐标信息,存入ts_x,ts_y*/
int get_ts(void)
{
//1,打开触摸屏文件
int fd = open(TS_PATH, O_RDWR);
if(-1 == fd)
{
perror("open ts failed");
return -1;
}
//2,读取触摸屏文件数据
struct input_event xy;
int flag = 0; //记录当前获取坐标的信息
while(1)
{
read(fd, &xy, sizeof(xy));
//printf("type:%d, code:%d, value:%d\n", xy.type, xy.code, xy.value);
if(xy.type == EV_ABS &&