mediaplayerfunc.c
来自「M3355的源代码」· C语言 代码 · 共 2,203 行 · 第 1/5 页
C
2,203 行
/************************MediaPlayerFunc.c****************************
*
* Copyright (C) 2003 by ALi Corporation. All Rights Reserved.
*
* File: MediaPlayerFunc.c
*
* Contents:
* Fileopen AP, to process user acts and notices from other levels
*
* History:
* Date By Reason Ver.
* =========================================================
* 2003/07 David cui, Diddy du creat For New MediaPlayer v1.0
*
***********************************************************************/
#include <comsub.h>
#include <ui.h>
#include <ui_sub.h>
#include <panel.h>
#include "../../cstm/fend/frntp.h"
#include "fileopen_NV.h"
#include "MediaPlayerFunc.h"
#include <atapi.h>
#include "setupfunc.h"
#ifdef _MPLAY_ENABLE_
//--> Gordon
#include "mediaplayeroutlook.h"
tRefreshParam iRefreshParam; // used as data interface between MPF and MPO (Draw Media Player Outlook)
extern tAuxliaryParam gAuxParam;// used as data interface between Normal and MPO (Draw Help, Progress Bar, Play Mode OSD, ... for Slide Show/Mix Play)
extern BOOL bDrawSlideShowHelp; // from Normal (Whether Slide Show Help visible or not)
//<-- Gordon
//maggie added for to fix the problem it will flash show a total track num and total time in autoplay
extern BYTE bFPLastplay;
//debug
//#define PRINTF(...)
//#define _DEBUG
#undef _DEBUG
#define MPF_error PRINTF("\n***** error in func %s line %d *****\n",__FUNCTION__,__LINE__)
#ifdef _DEBUG
#define DBG_PRINT(fmt, args...) PRINTF("MediaPlayerFunc.c -> " fmt, ##args)
#define ENTER_FUNCTION PRINTF("\n***** Enter %s *****\n",__FUNCTION__)
#define LEAVE_FUNCTION PRINTF("\n***** Leave %s from line %d *****\n",__FUNCTION__,__LINE__)
#else
#define DBG_PRINT
#define ENTER_FUNCTION
#define LEAVE_FUNCTION
#endif
#define MEANINGLESS 0xff
#if ( SKIP_LEVEL==Skip_Level_5 )
//--> Gordon, to get rid of warning. because it has been defined in ui.h, but the value is different, ATTN: cannot be the same, otherwise ff2==ff4==ff8, ...
#undef MinFastVal
#undef MaxFastVal
#undef MaxReverseVal
//<-- Gordon
#define MinFastVal 1
#define MaxFastVal 3
#define MinReverseVal 11
//#define MaxReverseVal 15 //31102-02jeff: Fast and Reverse ratio all error when x2->x4->x8->x2->x4
#define MaxReverseVal 13 //31102-02jeff: Fast and Reverse ratio all error when x2->x4->x8->x2->x4
#else
#define MinFastVal 6
#define MaxFastVal 7
#define MinReverseVal 11
#define MaxReverseVal 12
#endif
#define PLAY_NEXT 1
#define PLAY_PREV 0
#define C_USEROP 1
#define C_NOUSER 0
#define C_JUMP 1
#define C_NOJUMP 0
#define C_FOLLOW 1
#define C_NOFOLLOW 0
#define MPF_NOTHING 0xffff
#define C_NULL 0
//#define CUSTOM_LG 4
//#define _CUSTOM CUSTOM_LG
BYTE bJPGSlideMode = TRUE;
extern WORD wPlayNow;
extern BOOL bPauseToPlay;
BOOL bVcdLastPlay=FALSE;
WORD wShowedNum;//benjamin add ,means the number of jpeg which is acutually showed on screen;
//////////////////////////////////////////////////////////////////////
//
// MediaPlayer AP.........................................//
// it process user operation and all kinds of message.
// it is separate from display osd.
//////////////////////////////////////////////////////////////////////
//fileopen max program limit number
#define C_MPFFOPROMAX MAX_FILE_COUNT_SUPPORT
//cd max program limit number
#define C_MPFCDPROMAX 99
// for ID3 TAG
#define C_MPFCDPROMAX 99
typedef struct _MPF_Attr
{
WORD gMediaType; // Media Type from DT, eg: C_MP3FILE | C_JPGFILE
DWORD dwPlaytime; // the time for osd show
WORD wSurMode; // surround mode
BOOL bIntroMode; // intro play
WORD wFileCount; // current folder file count
WORD wItemCount; // current folder item count include file and dir
WORD wDiscFileCount[2]; // the disc file count
WORD wFilter; // music or photo or movie
tMediaPlayerObj iFocusObj; // only for RT_FEEDBACK
tMediaPlayerObj iPlayingObj; // only for RT_FEEDBACK
WORD wTransCurTrack; // only for show transition track when num play
WORD wListPlayingIndex; // 0 .. n, only for RT_FEEDBACK
WORD wListHighlightIndex; // 0 .. n, only for RT_FEEDBACK
WORD wListBeginIndex; // current list window top file number
}
MPF_ATTR;
/**************************************
* it must be static. anyone can't use *
* the variable in other file!!!!!!!!! *
***************************************/
static MPF_ATTR MPF_Attr;
//list info for display
//MPLIST_INFO *g_pListTab;
MPLIST_INFO g_pListTab[C_ITEMPERCOL] __attribute__ ((section ("GDIBUFFER")));
//the current path name
BYTE g_szCurDisPath[256];
//the current playing number for mix play
WORD MixPlayNum[2];
//mix play or slide show
//BYTE bMixPlay = FALSE;//Remove by 30908-01jeff for MixPlay Next and Prev
//TRUE: play prev track. FALSE: play cur track.
static BOOL bPrevStatus=FALSE;
//the program number for resume play
WORD wProgMemoryTrack;
//memory dir begin index
WORD wMemoryBeginIndex[C_DIRDEPTH];
//point current dir
WORD* pwDirDepth;
//current playing file dir
static WORD wPrevDirStartNum;
//current window dir
WORD wNowDirStartNum;
//current session number.
BYTE g_bCurSessionNum;
//current playing file session
BYTE g_bPrevSessionNum;
extern BOOL PlaybackModeChangeSuccess(BYTE list, BYTE repeatrange, BYTE method);
extern BOOL bOutOfMPO;
//session object count(NOTE: not session count)
extern BYTE g_bSessionCount;
extern BOOL bLogoState;
BYTE bsetuplastplay; //benjamin add,when press setup->play continously
//setup will exit and set to filopensubfunc,and send ui message
//lastplay key.but if at that time message buffer still exits
//setup key.then there is problem.First mediaplay proc exit itself
//and set current function as normalproc,then send setup key to ui
//but in message buffer ,there is lastkey before setup key,then go
//the wrong way and some important value is wrong
#define PROG_ITEM_MAX 199
WORD g_szProgList[PROG_ITEM_MAX];// __attribute__ ((section ("GDIBUFFER")));
WORD g_VCDProCurNum=0;
#define PROG_ITEM_NULL 0xFFFF
void MPF_Timer(void);
void insertProgItem(WORD iNum)
{
// int i=0;
// while(g_szProgList[i]!=PROG_ITEM_NULL)
// i++;
// if(i<PROG_ITEM_MAX)
// g_szProgList[i]=iNum;
g_szProgList[iNum]=iNum;
}
void deleteProgItem(WORD iNum)
{
int i=0;
// while(g_szProgList[i]!=iNum)
// i++;
// if(i<PROG_ITEM_MAX)
// g_szProgList[i]=PROG_ITEM_NULL;
g_szProgList[iNum]=PROG_ITEM_NULL;
i=0;
while(g_szProgList[i]==PROG_ITEM_NULL && i<PROG_ITEM_MAX)
i++;
if(i==PROG_ITEM_MAX) // program list is empty
g_UiPlaybackList=UI_PLAYBACKLIST_NORMAL;
}
WORD findProgItem(WORD iNum)
{
// int i;
// for(i=0; i<PROG_ITEM_MAX; i++)
// {
// if(g_szProgList[i]==iNum)
// return i;
// }
// return PROG_ITEM_NULL;
return g_szProgList[iNum];
}
int GetProgCurIndex(WORD num)
{
int i,j=0;
for(i=0; i<PROG_ITEM_MAX; i++)
{
if(g_szProgList[i]!=PROG_ITEM_NULL)
{
if(i==num)
{
return j;
}
j++;
}
}
return 0;
}
#if(_VCD_PROGRAM_MODE==_VCD_PROGRAM_ENABLE_)
BOOL CheckVCDKey( DWORD UserKey )
{
if(VirDiscType==C_VCD10)
{
if(UserKey==V_KEY_POWER||UserKey==V_KEY_OPEN||UserKey==V_KEY_STOP||UserKey==V_KEY_PLAY \
||UserKey==V_KEY_ENTER||UserKey==V_KEY_SETUP||UserKey==V_KEY_UP||UserKey==V_KEY_DOWN \
||UserKey==V_KEY_LEFT||UserKey==V_KEY_RIGHT||UserKey==V_KEY_RETURN||UserKey==V_KEY_CLEAR \
||UserKey==V_KEY_PROGRAM||UserKey==V_KEY_VOLUM||UserKey==V_KEY_DINTIAN_STOP||UserKey==V_KEY_LASTPLAY \
||UserKey==V_KEY_PAGEUP||UserKey==V_KEY_PAGEDOWN||UserKey==V_KEY_VOLDOWN||UserKey==V_KEY_VOLUP||UserKey==V_KEY_MUTE)
return TRUE;
else
return FALSE;
}
else
return TRUE;
}
void VCDExitMediaplayer(void)
{
int i;
tPositionInfo tMPFCurPosition;
MPO_GetPositionInfo(&tMPFCurPosition);
if(!(DiscType==C_CDDA||DiscType==C_DTSCD|| DiscType==C_HDCDDA||DiscType==C_FILEOPENDISC
))
{
if(bVcdLastPlay==FALSE)
{
g_UiPlaybackMethod=UI_PLAYBACKMETHOD_NORMAL;
bLastRandomStatus=UI_PLAYBACKMETHOD_NORMAL;
}
bVcdLastPlay=FALSE;
PlaybackModeChangeSuccess(g_UiPlaybackList, g_UiPlaybackRepeatRange,g_UiPlaybackMethod);
MPO_RefreshOutlook( RT_CLOSE,&iRefreshParam);
if(VirDiscType==C_VCD10)
{
delay(100);
}
VfdCloseLongKey(2);
if(g_UiCoreState==UI_CORE_PLAY)
VfdCloseLongKey(3);
g_UiCrntFunc = UI_FUNC_NORMAL;
g_UiCrntSubFunc=UI_SUBFUNC_BASAL;
(UiInitFunc[UI_FUNC_NORMAL])();
NextPrevStatus=1;
if(g_UiPlaybackList==UI_PLAYBACKLIST_PROGRAM)
ShowPlayModeGui(RS_FUN_OSD_PROGRAM, MSG_NULL);
}
}
void VCDEntry(void)
{
PLAYPOINT iPlayPoint;
VfdOpenLongKey(2);
NVGetCurInfo(&iPlayPoint);
if(g_UiCoreState==UI_CORE_STOP&&bIsSecondStop)
{
MPO_RefreshOutlook(RT_PLAYMODE_CHG, &iRefreshParam);
MPF_Attr.wListBeginIndex = 0;
MPF_Attr.wListHighlightIndex = 0;
MPF_Attr.wListPlayingIndex=MPF_NOTHING;
MPF_Attr.iPlayingObj=MPF_NOTHING;
}
else
{
MPF_Attr.wListPlayingIndex = iPlayPoint.wTTN-1;
MPF_Attr.wListHighlightIndex = iPlayPoint.wTTN-1;
MPF_Attr.wListBeginIndex=MPF_Attr.wListPlayingIndex+1-C_ITEMPERCOL>=0?MPF_Attr.wListPlayingIndex+1-C_ITEMPERCOL:0;
MPF_Attr.iPlayingObj=OBJ_LIST;
}
MPF_Attr.iFocusObj=OBJ_LIST;
FileOpenGetItemInfo( g_pListTab, MPF_Attr.wListBeginIndex, C_ITEMPERCOL, MPF_Attr.wFilter, MPF_Attr.wItemCount-MPF_Attr.wFileCount );
MPO_RefreshOutlook(RT_FEEDBACK, &iRefreshParam);
}
#endif
#ifdef _DEBUG
void showProgList()
{
int i;
for(i=0; i<PROG_ITEM_MAX; i+=10)
{
//MP_PRINTF("%d, %d, %d, %d, %d ----- %d, %d, %d, %d, %d\r\n", g_szProgList[i],g_szProgList[i+1],g_szProgList[i+2],g_szProgList[i+3],g_szProgList[i+4], g_szProgList[i+5],g_szProgList[i+6],g_szProgList[i+7],g_szProgList[i+8],g_szProgList[i+9]);
}
}
#endif
//////////////////////////////////////////////////////////////////////
//
// the below functions are interface for other file
//
//////////////////////////////////////////////////////////////////////
void SlideShowNext(int iNextNum);
void SlideShowPrev(int iPrevNum);
void MovieNext(int iNextNum);
void MoviePrev(int iPrevNum);
void MPF_Display();
/*--------------------------------------------------------------------
* Function_Name MPF_CheckFocusType
*
* Description:
* the interface of checking current file type .
* Arguments: Type:
* file type
* Return Value:
* 1:if correct 0:if not
*------------------------------------------------------------------*/
BOOL MPF_CheckFocusType(tFileType curFileType)
{//benjamin add
tPositionInfo tMPFCurPosition;
MPO_GetPositionInfo(&tMPFCurPosition);
if(curFileType==C_JPGFILE)
{
if(DiscType==C_FILEOPENDISC&&tMPFCurPosition.iPlayerFocused==MPLR_PHOTO)
{
return 1;
}
}
return FALSE;
}
/*--------------------------------------------------------------------
* Function_Name MPF_NextPrevProc
*
* Description:
* the interface of process next and previous key for other file * .
* Arguments: Type:
* UserKey: NOTE!! V_KEY_NEXT or V_KEY_PREV
* Return Value:
* NONE
*------------------------------------------------------------------*/
#if 0
void MPF_NextPrevProc(DWORD UserKey, int iNum)
{
tPositionInfo curPositionInfo;
MPO_GetPositionInfo(&curPositionInfo);
switch(UserKey)
{
case V_KEY_NEXT:
if(curPositionInfo.iPlayerFocused==MPLR_PHOTO)
SlideShowNext(iNum);
break;
case V_KEY_PREV:
if(curPositionInfo.iPlayerFocused==MPLR_PHOTO)
SlideShowPrev(iNum);
break;
}
}
#endif
/*--------------------------------------------------------------------
* Function_Name MPF_GetCurTrackNum
*
* Description:
* the interface of get cur position info.
* Arguments: Type:
* Return Value:
*------------------------------------------------------------------*/
void MPF_GetCurTrackNum(MPF_CurInfo* pMPFInfo)
{
tPositionInfo tMPFCurPosition;
WORD wTmpCount;
MPO_GetPositionInfo(&tMPFCurPosition);
wNowDirStartNum=FileOpenGetDirStartNum();
wTmpCount=FileOpenGetRemovedDirCount(wPrevDirStartNum);
pMPFInfo->iFocusObj=tMPFCurPosition.iFocusObj;
pMPFInfo->iPlayerFocused=tMPFCurPosition.iPlayerFocused;
pMPFInfo->wListHighlightIndex=tMPFCurPosition.wListHighlightIndex;
pMPFInfo->wListPlayingIndex=tMPFCurPosition.wListPlayingIndex_xDir;
if((g_bCurSessionNum!=g_bPrevSessionNum||wNowDirStartNum!=wPrevDirStartNum)&&(g_UiCoreState!=UI_CORE_STOP||bIsSecondStop==FALSE))
pMPFInfo->wDirCount=wTmpCount;
else
pMPFInfo->wDirCount=MPF_Attr.wItemCount-MPF_Attr.wFileCount;
pMPFInfo->wFileCount=MPF_Attr.wFileCount;
if(g_UiCoreState==UI_CORE_PLAY||g_UiCoreState==UI_CORE_PAUSE)//benjamin edited
{//benjamin change it,when mixplay we use this to get the picture number which is played
pMPFInfo->wCurJpegNum=wShowedNum+1;
}
else
{
if((tMPFCurPosition.wListHighlightIndex+1-(MPF_Attr.wItemCount-MPF_Attr.wFileCount)>MPF_Attr.wFileCount)||\
(tMPFCurPosition.wListHighlightIndex+1-(MPF_Attr.wItemCount-MPF_Attr.wFileCount)<0))
pMPFInfo->wCurJpegNum = MPF_Attr.wFileCount;
else
pMPFInfo->wCurJpegNum=tMPFCurPosition.wListHighlightIndex+1-(MPF_Attr.wItemCount-MPF_Attr.wFileCount);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?