Error[8]: Undefined offset: 48, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 114
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

该主题前面的链接

1.开箱  https://bbs.elecfans.com/jishu_2172464_1_1.html

2.sd卡 播放 https://bbs.elecfans.com/jishu_2173612_1_1.html

3.音量记忆、播放暂停功能实现 https://bbs.elecfans.com/jishu_2183725_1_1.html

 

此贴主要实现sd 卡根目录wav 文件搜索 ,并实现相应的播放

    [+++]

 

 

 

//通过后缀名识别文件类型
uint8_t [+++]ll_type(char *p)
{
    int i=0;
    char *attr;
    while(i<200)
    {
        if(*p=='
') break; i++; p++; } if(i==200) return 1; i=0; while(i<5) { if(*p=='.') { p++; attr=p; break; } i++; p--; } if(i==5) return 2; if((strcmp(attr,"WAV")==0)||(strcmp(attr,"wav")==0)) { return 0; } else { return 4; } }

 

2.扫描所有根目录文件,并记录wav个数及相应的index

uint16_t wavGetNum(uint8_t*path)
{
    DIR tdir;
    uint16_t rval =0;
    uint8_t* fn;
   // DWORD tmp;
    DWORD fileindex=0;
    uint8_t res = f_opendir(&tdir, (const TCHAR*)path);
    tfileinfo.fsize = 255;
    [+++](res ==FR_OK){
        //LOG_I("open root dir sucess");
        while(1){
            fileindex++;
           // tmp = tdir.dptr;
           // LOG_I("dir_ofset %d",tmp);
            res = f_re[+++]dir(&tdir, &tfileinfo);
            if(res!=FR_OK||tfileinfo.fname[0]==0){
                //LOG_I("found the end");
                break;
                }
            res =tell_type(tfileinfo.fname);
            if(res==0){
               // LOG_I("get the wav");
                wavIndex[rval] = fileindex-1;//get the index
                rval++;
            }
        }//endwhile
    }
    else{
        LOG_I("open root dir fail");
    }
    return rval;
}

3.在sd 卡mount 处进行 wav文件扫描,并获取相应的wav名称

uint8_t* getFilePath(uint32_t index,uint8_t* path)
{
    DIR fi[+++]ir;
    uint8_t *filepath =NULL;
    tfileinfo.fsize = 255;
    uint8_t res = f_opendir(&filedir, path);
    if(res == FR_OK){
       // LOG_I("dir_ofset %d",index);
        f_seekdir(&filedir, index);
       // LOG_I("dir_ofset %d",filedir.dptr);
        res =f_readdir(&filedir, &tfileinfo);
        if(res== FR_OK){
            //LOG_I("get the file %s",tfileinfo.fname);
            filepath = &wavFileName[0];
            strcpy(filepath,&tfileinfo.fname[0]);
        }
        else {
            LOG_I("open file name error");
        }
    }
    else{
        LOG_I("open root dir fail");
    }
    return filepath;
}

 

实际运行log

 pYYBAGF-SvmAI4WEAACTcomN1FA212.png <===>)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
[RTT-创新应用设计]AB32VG1-4.wav搜索_技术_内存溢出

[RTT-创新应用设计]AB32VG1-4.wav搜索

[RTT-创新应用设计]AB32VG1-4.wav搜索,第1张

该主题前面的链接

1.开箱  https://bbs.elecfans.com/jishu_2172464_1_1.html

2.sd卡 播放 https://bbs.elecfans.com/jishu_2173612_1_1.html

3.音量记忆、播放暂停功能实现 https://bbs.elecfans.com/jishu_2183725_1_1.html

 

此贴主要实现sd 卡根目录wav 文件搜索 ,并实现相应的播放

  1. 首先要通过字符串来识别是否是wav文件

 

 

 

//通过后缀名识别文件类型
uint8_t tell_type(char *p)
{
    int i=0;
    char *attr;
    while(i<200)
    {
        if(*p=='
') break; i++; p++; } if(i==200) return 1; i=0; while(i<5) { if(*p=='.') { p++; attr=p; break; } i++; p--; } if(i==5) return 2; if((strcmp(attr,"WAV")==0)||(strcmp(attr,"wav")==0)) { return 0; } else { return 4; } }

 

2.扫描所有根目录文件,并记录wav个数及相应的index

uint16_t wavGetNum(uint8_t*path)
{
    DIR tdir;
    uint16_t rval =0;
    uint8_t* fn;
   // DWORD tmp;
    DWORD fileindex=0;
    uint8_t res = f_opendir(&tdir, (const TCHAR*)path);
    tfileinfo.fsize = 255;
    if(res ==FR_OK){
        //LOG_I("open root dir sucess");
        while(1){
            fileindex++;
           // tmp = tdir.dptr;
           // LOG_I("dir_ofset %d",tmp);
            res = f_readdir(&tdir, &tfileinfo);
            if(res!=FR_OK||tfileinfo.fname[0]==0){
                //LOG_I("found the end");
                break;
                }
            res =tell_type(tfileinfo.fname);
            if(res==0){
               // LOG_I("get the wav");
                wavIndex[rval] = fileindex-1;//get the index
                rval++;
            }
        }//endwhile
    }
    else{
        LOG_I("open root dir fail");
    }
    return rval;
}

3.在sd 卡mount 处进行 wav文件扫描,并获取相应的wav名称

uint8_t* getFilePath(uint32_t index,uint8_t* path)
{
    DIR filedir;
    uint8_t *filepath =NULL;
    tfileinfo.fsize = 255;
    uint8_t res = f_opendir(&filedir, path);
    if(res == FR_OK){
       // LOG_I("dir_ofset %d",index);
        f_seekdir(&filedir, index);
       // LOG_I("dir_ofset %d",filedir.dptr);
        res =f_readdir(&filedir, &tfileinfo);
        if(res== FR_OK){
            //LOG_I("get the file %s",tfileinfo.fname);
            filepath = &wavFileName[0];
            strcpy(filepath,&tfileinfo.fname[0]);
        }
        else {
            LOG_I("open file name error");
        }
    }
    else{
        LOG_I("open root dir fail");
    }
    return filepath;
}

 

实际运行log

 [RTT-创新应用设计]AB32VG1-4.wav搜索,pYYBAGF-SvmAI4WEAACTcomN1FA212.png,第2张

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/dianzi/2434984.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-08-02
下一篇 2022-08-02

发表评论

登录后才能评论

评论列表(0条)

保存