⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enhanced_selector_api_for_ape.c

📁 MP3 整个 SDK
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*******************************************************************************
*                File selector 
*            enhanced library
*
*        (c) Copyright, Actions Co,Ld.                             
*             All Right Reserved                          
*
*******************************************************************************
*/ 


#include "actos.h"
#include "enhanced.h"
#include "debug.h"

//global variable should be resident
BYTE    fselPLOrCommonDir;
BYTE    fselType;      //Type of select,  Music or voice.
BYTE    fselMode;    //Mode of select, Sequence, repeat one ...
WORD    fselFileNo;    //Number of current file, 
                //=0 mean NULL, 1 mean first file
#ifdef __APE_SUPPORT
extern  WORD    fselFileNo_APE;    //Number of current file no with total APE parts of current and last in ape file
extern  BYTE    Curfilename[12];
extern  BYTE    CurApe_TotalNo;
#endif
BYTE    fselExtNo; //Number of current file ext name..
                //== 0xff  Initialized status, should restart select.
char    fselDiskLetter;
BYTE    fselError;    // store error id;
WORD    fselRandCount;
BYTE    fselDirNo[TOTALDIRLAYER];    //Number of current valid directory
                    //=0 mean NULL, 1 mean first valid directory
BYTE    fselDirLayer;   //当前目录层次.与fselDirNo[]共同记录当前目录在目录树中的位置.
//************************************************************************
//fselDirLayer == 0, fselDirNo[0] == 0; 表示根目录
//fselDirLayer == 0, fselDirNo[0] == 1; 表示根目录下第一个子目录.
//fselDirLayer == 1, fselDirNo[0] == 1, fselDirNo[1] == 1;表示根目录下第一个子目录中第一个子目录.
//************************************************************************
WORD    fselTotal;  //Total of current select file

extern  WORD    fselFileNo_APE;    //Number of current file no with total APE parts of current and last in ape file
extern  BYTE    Curfilename[12];
extern  handle  fpPlaylist;         //playlist handle    
extern  BYTE    fselMode;   //opened file selector mode

extern  WORD    PlaylistClassTotal; //the total class of the playlist file
extern  WORD    PlaylistItemTotal;  //the total of the same class songs
extern  WORD    PlaylistCurClass;   //1 ~ PlaylistClassTotal
extern  WORD    PlaylistCurItem;    //1 ~ ClassItemTotal

extern  WORD    ClassItemTotal;

extern  BYTE    PlayListFileName[12]; //the opened file name of playlist
extern  BYTE    ItemFileName[12];


extern  BOOL ToDirEntry(char *strDir, const WORD Num);  //through the no get the dir name
extern  BOOL getClassParam(char *classname, WORD strlen);   //get the current class name and parament
extern  WORD Random(void);  //random function ,used by get the next or prev file funciton
extern  BYTE getplayItemparam(char *filename);

#pragma memory=constseg(MOC_EH_FSLAPI)
const char IgnoreExt4[4] = {"*  "};
//const char APEExt4[]         = "APE";
#pragma memory=default

#pragma memory=dataseg(MOD_EH_FSLAPI)
char playlistclassname[28]; 
#pragma memory=default
#pragma codeseg(MO_EH_FSLAPI)
/********************************************************************************
* Description : get the next file in playlist or common file system 
*
* Arguments  :
*             filename : output the next filename
* Returns     :
*            TRUE: Successful,
*            FALSE: Fail, detail information in fselError.
* Notes       :in common type, it call fselGetNext
*
********************************************************************************/
BOOL fselGetNextFile(char *filename)
{
    BYTE    iTime;
    iTime = 0;
    if (fselPLOrCommonDir == FSEL_TYPE_COMMONDIR)   //comon file system
    {
        return fselGetNext(filename);
    }
    else if (fselPLOrCommonDir == FSEL_TYPE_PLAYLIST)  //playlist file system
    {
        if (!fpPlaylist)    //must open the playlist
        {
            fselError = FSEL_ERR_PLAYLIST;
            return FALSE;
        }
        switch(fselMode)
        {
            case FSEL_ALL_REPEATONE:  //current file
                 { // handle the case of repeat one
                     if ( getplayItemparam(filename) == 1 )       //默认输入:PlaylistCurItem
                     {
                         return TRUE;
                     }
                     else
                     {
                         fselError = FSEL_ERR_PLAYLIST;
                         return FALSE;
                     }
                 }
                 break;

            case FSEL_DIR_RANDOM:  //random file in current class
                 {
                     // handle the case of random
                     PlaylistCurItem = Random() % ClassItemTotal;

                     if (playlistnext(filename))
                         return TRUE;
                     else
                     {
                         fselError = FSEL_ERR_PLAYLIST;
                         return FALSE;
                     }
                 }
                 break;

            case FSEL_DIR_SEQUENCE: //sequence get the next file in current class
            case FSEL_DIR_INTRO:
                 {
                     if ( PlaylistCurItem >= ClassItemTotal )
                     {
                         return FALSE;
                     }
                     else
                     {
                         return playlistnext(filename);
                     }
                 }
                 break;

            case FSEL_ALL_SEQUENCE:     //all file sequence select the next file
                 {
RETRY:
                     if ( PlaylistCurItem >= ClassItemTotal ) //当前class item已播放完
                     {
                         if ( PlaylistClassTotal == 0 )
                         {
                             fselError = FSEL_ERR_OUTOF;
                             return FALSE;
                         }
                         else if ( PlaylistCurClass >= PlaylistClassTotal )  //the last class ,return
                         {
                             fselError = FSEL_ERR_OUTOF;
                             return FALSE;
                         }
                         else if ( playlistclassNext(playlistclassname) ) //get the next class
                         {
                             if (playlistnext(filename))
                                 return TRUE;
                             else
                             {
                                 iTime ++;
                                 if (iTime >5 )      //最多循环找后5个目录??
                                     return FALSE;
                                 goto RETRY;
                             }
                         }
                         else
                             return FALSE;
                     }
                     else if (playlistnext(filename))  //the same class get the next file
                     {
                         return TRUE;
                     }
                     else
                     {
                         iTime ++;
                         if (iTime >5 )
                             return FALSE;
                         goto RETRY;
                     }
                 }
                 break;

            case FSEL_ALL_REPEATALL:
                 {
RETRYALL:
                    if ( PlaylistCurItem >= ClassItemTotal ) //get the next class file
                    {
                       if ( PlaylistCurClass >= PlaylistClassTotal ) //reached last class, get the first class
                       {
                           PlaylistCurClass = 0;      //轮转回第一个class-1
                       }

                       if (playlistclassNext(playlistclassname)) //next class
                       {
                           if (playlistnext(filename))
                               return TRUE;
                           else
                           {
                               iTime ++;
                               if (iTime >5 )
                                   return FALSE;
                               goto RETRYALL;
                           }
                       }
                       else
                       {
                           return FALSE;
                       }
                    }
                    else if (playlistnext(filename)) //get the next file in the same class
                    {
                        return TRUE;
                    }
                    else
                    {
                        iTime ++;
                        if (iTime >5 )
                            return FALSE;
                        goto RETRYALL;
                    }
                 }
                 break;

            case FSEL_DIR_REPEATALL:  // in the same class get the file
                 {
                     if ( PlaylistCurItem >=  ClassItemTotal ) // reached the last , get the first
                     {
                         PlaylistCurItem = 0;
                     }
                     return playlistnext(filename);
                 }
                 break;

            default:
                return FALSE;
        }   //switch
    }
    else
        return FALSE;
}

/********************************************************************************
* Description : get the prev file in playlist or common file system 
*
* Arguments  :
*             filename : output the prev filename
* Returns     :
*            TRUE: Successful,
*            FALSE: Fail, detail information in fselError.
* Notes       :in common type, it call fselGetPrev
*
********************************************************************************/
BOOL fselGetPrevFile(char *filename)
{
    BYTE iTime;      
    iTime = 0;
    if (fselPLOrCommonDir == FSEL_TYPE_COMMONDIR)   //comon file system
    {
        return fselGetPrev(filename);
    }
    else if (fselPLOrCommonDir == FSEL_TYPE_PLAYLIST)   //playlist system
    {
        if (!fpPlaylist)    //must open the playlist file
        {
            fselError = FSEL_ERR_PLAYLIST;
            return FALSE;
        }
        switch(fselMode)    //begin select mode
        {
            case FSEL_ALL_REPEATONE:    //current file paly
            { // handle the case of repeat one
                if ( getplayItemparam(filename) == 1 )       //默认输入:PlaylistCurItem
                {
                    return TRUE;
                }
                else
                {
                    fselError = FSEL_ERR_PLAYLIST;
                    return FALSE;
                }
            }
            break;

            case FSEL_DIR_RANDOM:   //random file play in current class
            {
                // handle the case of random
                PlaylistCurItem = Random() % ClassItemTotal;

                if (playlistprev(filename))
                    return TRUE;
                else
                {
                    fselError = FSEL_ERR_PLAYLIST;
                    return FALSE;
                }
            }
            break;

            case FSEL_DIR_SEQUENCE: //in current class sequence play
            case FSEL_DIR_INTRO:
            {
                if ( PlaylistCurItem <= 1 )
                {
                    return FALSE;
                }
                else
                {
                    return playlistprev(filename);
                }
            }
            break;

            case FSEL_ALL_SEQUENCE: // sequence play in all playlist file
            {
RETRY:
                if ( PlaylistCurItem <= 1 ) //当前class item已播放完
                {
                    if ( PlaylistClassTotal == 0 )
                    {
                        fselError = FSEL_ERR_OUTOF;
                        return FALSE;
                    }
                    else if ( PlaylistCurClass <= 1  )  //the first class ,return
                    {
                        fselError = FSEL_ERR_OUTOF;
                        return FALSE;
                    }
                    else if ( playlistclassPrev(playlistclassname) ) //get the prev class
                    {
                        if (playlistprev(filename))
                            return TRUE;
                        else
                        {
                            iTime ++;
                            if (iTime >5 )      //最多循环找后5个class??
                                return FALSE;
                            goto RETRY;
                        }
                    }
                    else
                        return FALSE;
                }
                else if (playlistprev(filename)) // get the prev file in the same class
                {
                    return TRUE;
                }
                else
                {
                    iTime ++;
                    if (iTime >5 )
                        return FALSE;
                    goto RETRY;
                }
            }
            break;

            case FSEL_ALL_REPEATALL:  // All file repeat play
            {
RETRYALL:
                if ( PlaylistCurItem <= 1 ) //get the next class file
                {
                    if ( PlaylistCurClass <= 1 ) //reached first class, get the first class
                    {
                        PlaylistCurClass = PlaylistClassTotal + 1;
                    }

                    if (playlistclassPrev(playlistclassname))   //get the prev class
                    {
                        PlaylistCurItem = ClassItemTotal + 1;
                        
                        if (playlistprev(filename))
                            return TRUE;
                        else
                        {
                            iTime ++;
                            if (iTime >5 )
                                return FALSE;
                            goto RETRYALL;
                        }
                    }
                    else
                    {
                        return FALSE;
                    }
                }
                else if (playlistprev(filename)) //get the prev file in the same class
                {
                    return TRUE;
                }
                else
                {
                    iTime ++;
                    if (iTime >5 )
                        return FALSE;
                    goto RETRYALL;
                }
            }
            break;

            case FSEL_DIR_REPEATALL: //current dir repeat play
            {
                if ( PlaylistCurItem <=  1 ) // reached the last , get the first

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -