BOOL FlowMovie_CheckMemoryForCyclicRec(UINT32 uiCyclicRecTime)
{

    UINT32  err;
	PFILEDB_FILE_ATTR FileAttr = NULL;
	INT32             ret;
	int i = 0;
	i = 1;
       if(System_OnStrgIsFileSystemOK()==FALSE)
       {
	     debug_msg("File system not ok ,return ..\r\n");                            
            return FALSE;
       }
       FileSys_WaitFinish();
	debug_msg("^G ==  uiCyclicRecTime : %d      :  %d\r\n",uiCyclicRecTime*2,UIMovRecObj_GetData(RECMOVIE_MAXSECOND));
	while (uiCyclicRecTime*2 >= (UIMovRecObj_GetData(RECMOVIE_MAXSECOND)))
    	{
    	FileDB_Refresh(0);
    	FileAttr = FileDB_SearhFile2(0,i);
		if(FileAttr->attrib == 33)
		{
		/*
		 ret = FileSys_SetAttrib(FileAttr->filePath,FST_ATTRIB_READONLY,FALSE);
		 if (ret == FST_STA_OK)
		 	{
		 	FileAttr->attrib &=(~FS_ATTRIB_READ);
		 	}
		 	*/
		 
		}
		else
			{
			debug_msg("^G ==  no room for  loop rec   then   del   file : %s\r\n",FileAttr->filePath);
			if(FST_STA_OK==FileSys_DeleteFile(FileAttr->filePath))
                      {
	        	    FileSys_WaitFinish();
			    FileDB_Refresh(0);
			}			
                     else
                     {
			        debug_msg("File system error ,return ..\r\n");                     
                            return FALSE;
                     }
			}
		i++;
    	}
    if (uiCyclicRecTime*2 >= UIMovRecObj_GetData(RECMOVIE_MAXSECOND))
    {
    	Ux_OpenWindow(&UIFlowWndWrnMsgCtrl,2,UIFlowWndWrnMsg_StatusTXT_Msg_STRID_CARD_FULL,FLOWWRNMSG_TIMER_2SEC);
		return TRUE;
    }
	else
	{
	return FALSE;
	}
    
}
EVENT_END

static void UIFlowWndPlay_CheckStatus(void)
{
    UINT32 uiStatus, uiCurrMode;
    uiStatus = AppPlay_GetData(PLAY_PBSTATUS);
    uiCurrMode = AppPlay_GetData(PLAY_CURRMODE);

    // Decode Error & Read Error
    if( uiStatus & (PB_STA_ERR_FILE | PB_STA_ERR_DECODE) )
    {
        if(uiCurrMode == PLAYMODE_AVI || uiCurrMode == PLAYMODE_MOVMJPG)
        {
            UINT32  uiBuffAddr, uiBuffSize;
            CHAR    chaFullName[64] = { 0 };

            PB_GetParam(PBPRMID_DATABUF_ADDR, &uiBuffAddr);
            PB_GetParam(PBPRMID_DATABUF_SIZE, &uiBuffSize);
            PB_GetParam(PBPRMID_CURR_FILEPATH, (UINT32 *)&chaFullName);
            MediaPlay_FileRecovery(chaFullName, uiBuffAddr, uiBuffSize);
#if USE_FILEDB
            FileDB_Refresh(0); // should refresh FileDB
#else
            DCF_Refresh(); // should refresh DCF
#endif
            Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_PLAYSINGLE, 1, PB_SINGLE_CURR);
            uiStatus = AppPlay_GetData(PLAY_PBSTATUS);
            if( uiStatus == PB_STA_DONE)
                return;
        }
        Ux_OpenWindow(&UIFlowWndWrnMsgCtrl,2,FLOWWRNMSG_ISSUE_PICTURE_ERR,FLOWWRNMSG_TIMER_KEEP);
    }
}
INT32 SetupExe_OnFILEDB_FILEID_RESET(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray)
{
#if USE_FILEDB
 PFILEDB_FILE_ATTR  pFileAttr;
 int curfilenameLen;
 CHAR FileIndex[8]={0};

    FileDB_Refresh(0);
    if (FileDB_GetTotalFileNum(0))
    {
        pFileAttr = FileDB_CurrFile(0);
        curfilenameLen = strlen(pFileAttr->filename);
        strncpy(FileIndex, pFileAttr->filename+curfilenameLen-7, 3);
        debug_msg("fileid:%d\r\n",atoi(FileIndex));
        NH_FileDB_SetFileID(atoi(FileIndex));
    } else {
        debug_msg("fileid:%d\r\n",0);
        NH_FileDB_SetFileID(0);
    }
#endif
    return NVTEVT_CONSUME;
}