📄 musicplayer_waitfile.c
字号:
/********************************************************************************
* SDK30F_D1
* music player main sub
*
* (c) Copyright 2002, Actions Co,Ld.
* All Right Reserved
*
* File: musicplayer_WaitFile.c
* By : wurui
* Version: 1> v1.00 first version 2005-10-28 8:28
*
* $Id: musicplayer_WaitFile.c,v 1.4 2005/11/26 11:24:19 wurui Exp $
*******************************************************************************
*/
#include "MusicPlayer.h"
#include "device.h"
#include "my_os_q.h"
#include "task_cfg.h"
/*
********************************************************************************
* int MusicPlayer_SetLocation(music_t *g_music_vars)
*
* Description : 播放器检查用户参数正确与否,并获取音乐ID3信息
*
* Arguments : g_music_vars : musicplayer 任务变量指针
*
* Returns : 操作正常返回true,如果存在错误则返回 false
*
* Notes :
*
********************************************************************************
*/
int MusicPlayer_SetLocation(music_t *g_music_vars)
{
msg_t msg_send;
if( g_music_vars->infomation.fileno > g_music_vars->infomation.totalno)
g_music_vars->infomation.fileno = 1;
g_music_vars->music_type = CheckMusicType(g_music_vars->infomation.FifoCntNo, g_music_vars->infomation.fileno, g_music_vars->infomation.filename);
if(g_music_vars->music_type == Music_NON)
{
//g_music_vars->infomation.fileno = 1;
//if((g_music_vars->music_type = CheckMusicType(g_music_vars->infomation.FifoCntNo, g_music_vars->infomation.fileno, g_music_vars->infomation.filename)) == Music_NON)
return FileFormatErr;
}
return GetInformation(g_music_vars); //取文件信息
}
/*
********************************************************************************
* int MusicPlayer_compute_music_time_start(music_t *g_music_vars)
*
* Description : 启动DSP计算总时间
*
* Arguments : g_music_vars : musicplayer 任务变量指针
*
* Returns : 操作正常返回0,如果存在错误则返回错误类型
*
* Notes :
*
********************************************************************************
*/
int MusicPlayer_compute_music_time_start(music_t *g_music_vars)
{
int result;
if( (result = api_OpenFileByNo(g_music_vars->infomation.FifoCntNo, g_music_vars->infomation.fileno)) < 0)
{
_MusicPlayer_Exceptions(g_music_vars, FifoOpenErr);
return FSErr;
}
g_music_vars->infomation.fileflag = TRUE;
g_music_vars->infomation.fileLength = api_GetFileLength(g_music_vars->infomation.FifoCntNo);
if( (result = api_ReadFile(g_music_vars->infomation.FifoCntNo, g_music_vars->bit_stream, 512)) < 0)
{
_MusicPlayer_Exceptions(g_music_vars, FifoReadErr);
return FSErr;
}
music_api_Play(g_music_vars->music_type, Compute_Timer, g_music_vars->infomation.fileLength);
return 0;
}
/*
********************************************************************************
* int GetInformation(music_t *g_music_vars)
*
* Description : 读取歌曲信息,歌词
*
* Arguments : musicplayer 任务变量指针
*
* Returns : 操作正常返回0,如果存在错误则返回错误类型
*
* Notes :
*
********************************************************************************
*/
int GetInformation(music_t *g_music_vars)
{
return 0;
/*
int result;
ID3Info_t ID3;
//清 WATCH_DOG
output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
g_currentMusicType = CheckMusicType(g_music_vars.infomation.MusicLocationName);
ID3.TIT2_length = 30;
ID3.TPE1_length = 30;
ID3.TALB_length = 30;
ID3.TENC_length = 0;
ID3.TIT2_buffer = & g_TagInfoBuf[0];
ID3.TPE1_buffer = & g_TagInfoBuf[30];
ID3.TALB_buffer = & g_TagInfoBuf[60];
ID3.TENC_buffer = & g_TagInfoBuf[90];
switch (g_currentMusicType)
{
case Music_WMA:
case Music_WMV:
case Music_ASF:
ID3.TALB_length = 0;
if (wmaGetTAGInfo(g_music_vars.infomation.MusicLocationName, &ID3))
{
unitochar(g_TagInfoBuf, 30, g_comval.langid);
unitochar(&g_TagInfoBuf[30], 30, g_comval.langid);
if ( (g_TagInfoBuf[0] !=0)
|| (g_TagInfoBuf[30] !=0) )
{
strcpy(g_TagInfoBuf, & g_TagInfoBuf[0]);
strcat(g_TagInfoBuf, " ");
strcat(g_TagInfoBuf, & g_TagInfoBuf[30]);
strcat(g_TagInfoBuf, " ");
}
}
else
{
g_TagInfoBuf[0] = 0x0;
}
break;
case Music_MP3:
if (mp3GetID3Info(g_music_vars.infomation.MusicLocationName, & ID3, g_comval.langid))
{
strcpy(g_TagInfoBuf, & g_TagInfoBuf[0]);
strcat(g_TagInfoBuf, " ");
strcat(g_TagInfoBuf, & g_TagInfoBuf[30]);
strcat(g_TagInfoBuf, " ");
strcat(g_TagInfoBuf, & g_TagInfoBuf[60]);
strcat(g_TagInfoBuf, " ");
}
else
{
g_TagInfoBuf[0] = 0x0;
}
break;
case Music_OGG:
{
g_TagInfoBuf[0] = 0x0;
}
break;
default:
g_TagInfoBuf[0] = 0x0;
break;
}
// 显示信息区
//g_music_vars.infomation.MusicLocationName[12] = 0;
//---处理没有TAG信息的情况
if (g_TagInfoBuf[0] == 0)
{
memcpy(g_TagInfoBuf, g_music_vars.infomation.MusicLocationName, 12);
//if ((g_TagInfoBuf[5] == '~') || (g_TagInfoBuf[6] == '~'))
{
result = FS_GetName(g_TagInfoBuf, 31); //取出长名
if (result != 0)
{
unitochar(g_TagInfoBuf, sizeof(g_TagInfoBuf), g_comval.langid);
}
else
{
memcpy(g_TagInfoBuf, g_music_vars.infomation.MusicLocationName, 12);
}
}
}
//---在TAG信息后加个空格避免滚屏时串在一起
for (result = 0; result<sizeof(g_TagInfoBuf); result++)
{
if (g_TagInfoBuf[result] == 0)
{
g_TagInfoBuf[result] = ' ';
g_TagInfoBuf[result + 1] = 0;
break;
}
}
//清 WATCH_DOG
output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
#ifdef OPT_Sup_LRC_fun//支持歌词显示功能
BankSwitch((unsigned long)lyricQueryExist >> 16);
g_lyricflag = lyricQueryExist(g_music_vars.infomation.MusicLocationName);
if (g_lyricflag)
{
g_lyric_mod = lyricLoad(g_music_vars.infomation.MusicLocationName, g_TagInfoBuf);
}
if (g_lyric_mod == 0)
{
g_lyricflag = FALSE;
}
#endif //OPT_Sup_LRC_fun
//清 WATCH_DOG
output8(REG4E_RTC_WATCH_DOG, input8(REG4E_RTC_WATCH_DOG) | 0x08);
*/
}
/*
********************************************************************************
* Music_type_t CheckMusicType(char *MusicLocationName)
*
* Description : 检测当前是哪种类型的MUSIC文件
*
* Arguments : char *filename 文件名
*
* Returns : Music_type_t 文件类型
*
* Notes :
*
********************************************************************************
*/
music_type_t CheckMusicType( int fifocntno, int fileno ,char *filename)
{
char ExtMusicstr [MUSIC_TOTAL_TYPE] [3];
BYTE ext[4];
BYTE offset;
BYTE i = 0;
int result;
//char filename[32];
if( (result = api_GetFileNameByNo(fifocntno,filename,fileno)) < 0)
//return Music_NON;
_MusicPlayer_Exceptions((void*)0, FifoNameErr);
ExtMusicstr[0][0] = 'M';
ExtMusicstr[0][1] = 'P';
ExtMusicstr[0][2] = '3';
ExtMusicstr[1][0] = 'W';
ExtMusicstr[1][1] = 'M';
ExtMusicstr[1][2] = 'A';
ExtMusicstr[2][0] = 'A';
ExtMusicstr[2][1] = 'S';
ExtMusicstr[2][2] = 'F';
ExtMusicstr[3][0] = 'W';
ExtMusicstr[3][1] = 'M';
ExtMusicstr[3][2] = 'V';
ExtMusicstr[4][0] = 'O';
ExtMusicstr[4][1] = 'G';
ExtMusicstr[4][2] = 'G';
ExtMusicstr[5][0] = 'W';
ExtMusicstr[5][1] = 'A';
ExtMusicstr[5][2] = 'V';
ExtMusicstr[6][0] = 'A';
ExtMusicstr[6][1] = 'C';
ExtMusicstr[6][2] = 'T';
ExtMusicstr[7][0] = 'M';
ExtMusicstr[7][1] = '4';
ExtMusicstr[7][2] = 'A';
ExtMusicstr[8][0] = 'A';
ExtMusicstr[8][1] = 'G';
ExtMusicstr[8][2] = '8';
ExtMusicstr[9][0] = 'A';
ExtMusicstr[9][1] = 'G';
ExtMusicstr[9][2] = '4';
if(strlen(filename) != 12)
{
for(offset = 0;filename[offset++]!= '.' ;)
if(offset == 60)
return Music_NON;
}
else
offset = 9;
memcpy(ext, filename + offset, 3);
ext[0] = (ext[0]>='a' && ext[0]<='z') ? ext[0] - 'a' + 'A' : ext[0];
ext[1] = (ext[1]>='a' && ext[1]<='z') ? ext[1] - 'a' + 'A' : ext[1];
ext[2] = (ext[2]>='a' && ext[2]<='z') ? ext[2] - 'a' + 'A' : ext[2];
ext[3] = 0;
while(i < MUSIC_TOTAL_TYPE)
{
// if( (ext[0] == ExtMusicstr[i][0]) & (ext[1] == ExtMusicstr[i][1]) & (ext[2] == ExtMusicstr[i++][2]))
if(memcmp(ext, ExtMusicstr[i++], 3) == 0)
return i; //MUSIC TYPE ID
//i++;
}
return Music_NON;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -