📄 interface.c
字号:
RefreshButton(p,PLAYER_FULLSCREEN,&p->FullScreen,IF_OPTIONS_FULLSCREEN,-1,-1);
}
if (p->Skin[p->SkinNo].Valid) p->Skin[p->SkinNo].Hidden = State;
if (p->WndTrack) ShowWindow(p->WndTrack,State ? SW_HIDE:SW_SHOWNA);
if (p->WndTitle) ShowWindow(p->WndTitle,State ? SW_HIDE:SW_SHOWNA);
WinSetFullScreen(&p->Win,State);
if (p->Win.WndTB) UpdateWindow(p->Win.WndTB);
ShowVol(p,!State); // called after WinSetFullScreen so TOPMOST is over taskbar
if (State)
{
p->Player->Set(p->Player,PLAYER_FULLSCREEN,&State,sizeof(State));
p->Player->Set(p->Player,PLAYER_UPDATEVIDEO,NULL,0);
RefreshButton(p,PLAYER_FULLSCREEN,&p->FullScreen,IF_OPTIONS_FULLSCREEN,-1,-1);
}
}
return State;
}
static bool_t Toggle(intface* p,int Param,int Force)
{
bool_t State = 0;
if (p->Player->Get(p->Player,Param,&State,sizeof(State))==ERR_NONE)
{
assert(Param != PLAYER_FULLSCREEN);
if (State==Force)
return State;
State = !State;
p->Player->Set(p->Player,Param,&State,sizeof(State));
if (Param == PLAYER_PLAY)
RefreshButton(p,PLAYER_PLAY,&p->Play,IF_PLAY,0,1);
else
if (Param == PLAYER_FFWD)
RefreshButton(p,PLAYER_FFWD,&p->FFwd,IF_FASTFORWARD,4,1);
else
RefreshButton(p,Param,NULL,0,0,0);
}
return State;
}
static bool_t IsAutoRun(intface* p, const tchar_t* CmdLine)
{
while (IsSpace(*CmdLine))
++CmdLine;
return tcsnicmp(CmdLine,T("-autorun"),8)==0;
}
static void EnumDir(const tchar_t* Path,const tchar_t* Exts,player* Player)
{
streamdir DirItem;
stream* Stream = GetStream(Path,1);
if (Stream)
{
int Result = Stream->EnumDir(Stream,Path,Exts,1,&DirItem);
while (Result == ERR_NONE)
{
tchar_t FullPath[MAXPATH];
AbsPath(FullPath,TSIZEOF(FullPath),DirItem.FileName,Path);
if (DirItem.Size < 0)
EnumDir(FullPath,Exts,Player);
else
if (DirItem.Type == FTYPE_AUDIO || DirItem.Type == FTYPE_VIDEO)
{
int n;
Player->Get(Player,PLAYER_LIST_COUNT,&n,sizeof(n));
Player->Set(Player,PLAYER_LIST_URL+n,FullPath,sizeof(FullPath));
}
Result = Stream->EnumDir(Stream,NULL,NULL,0,&DirItem);
}
NodeDelete((node*)Stream);
}
}
void ProcessCmdLine( intface* p, const tchar_t* CmdLine)
{
int n;
tchar_t URL[MAXPATH];
if (IsAutoRun(p,CmdLine))
{
// search for media files on SD card
tchar_t Base[MAXPATH];
int* i;
array List;
tchar_t* s;
int ExtsLen = 1024;
tchar_t* Exts = malloc(ExtsLen*sizeof(tchar_t));
if (!Exts)
return;
Exts[0]=0;
NodeEnumClass(&List,FORMAT_CLASS);
for (i=ARRAYBEGIN(List,int);i!=ARRAYEND(List,int);++i)
{
const tchar_t* s = LangStr(*i,NODE_EXTS);
if (s[0])
{
if (Exts[0]) tcscat_s(Exts,ExtsLen,T(";"));
tcscat_s(Exts,ExtsLen,s);
}
}
ArrayClear(&List);
n = 0;
p->Player->Set(p->Player,PLAYER_LIST_COUNT,&n,sizeof(n));
GetModuleFileName(GetModuleHandle(NULL),Base,MAXPATH);
s = tcsrchr(Base,'\\');
if (s) *s=0;
s = tcsrchr(Base,'\\');
if (s) *s=0;
EnumDir(Base,Exts,p->Player);
free(Exts);
}
else
{
while (IsSpace(*CmdLine))
++CmdLine;
if (*CmdLine == '"')
{
tchar_t* ch = tcschr(++CmdLine,'"');
if (ch) *ch=0;
}
tcscpy_s(URL,TSIZEOF(URL),CmdLine);
p->CmdLineMode = 1;
n = 1;
p->Player->Set(p->Player,PLAYER_LIST_COUNT,&n,sizeof(n));
PlayerAdd(p->Player,0,URL,NULL);
}
n = 0;
p->Player->Set(p->Player,PLAYER_LIST_CURRIDX,&n,sizeof(n));
if (!IsWindowEnabled(p->Win.Wnd))
Toggle(p,PLAYER_PLAY,0);
}
void SetTrackPos(intface* p,int x)
{
fraction Percent;
RECT r,rt;
int Adj;
if (p->TrackSetPos == x)
return;
p->TrackSetPos = x;
SendMessage(p->WndTrack,TBM_GETCHANNELRECT,0,(LONG)&r);
SendMessage(p->WndTrack,TBM_GETTHUMBRECT,0,(LONG)&rt);
Adj = (rt.right-rt.left) >> 1;
r.left += Adj;
r.right -= (rt.right-rt.left)-Adj;
if (x > 32768) x -= 65536;
if (r.right <= r.left) r.right = r.left+1;
if (x < r.left) x = r.left;
if (x > r.right) x = r.right;
x = Scale(TRACKMAX,x-r.left,r.right-r.left);
Percent.Num = x;
Percent.Den = TRACKMAX;
p->Player->Set(p->Player,PLAYER_PERCENT,&Percent,sizeof(Percent));
}
LRESULT CALLBACK TitleProc(HWND WndTitle, UINT Msg, WPARAM wParam, LPARAM lParam)
{
intface* p = (intface*) WinGetObject(WndTitle);
if (p)
{
PAINTSTRUCT Paint;
RECT r;
tchar_t Time[32];
switch (Msg)
{
case WM_ERASEBKGND:
GetClientRect(WndTitle,&r);
FillRect((HDC)wParam,&r,p->TitleBrush ? p->TitleBrush:GetSysColorBrush(COLOR_BTNFACE));
break;
case WM_SIZE:
p->UpdateScroll = 1;
break;
case WM_LBUTTONDOWN:
break;
case WM_MOUSEMOVE:
break;
case WM_LBUTTONUP:
break;
case WM_PAINT:
BeginPaint(WndTitle,&Paint);
SelectObject(Paint.hdc,p->TitleFont);
SetBkColor(Paint.hdc,p->TitleFace);
SetTextColor(Paint.hdc,p->TitleText);
#if !defined(TARGET_WINCE)
SetTextAlign(Paint.hdc,TA_LEFT);
#endif
if (!p->TitleTimeWidth)
{
SIZE Size;
tchar_t* s;
tchar_t Dur[32];
tick_t Duration;
tchar_t TitleName[256];
node* Format;
if (p->Player->Get(p->Player,PLAYER_FORMAT,&Format,sizeof(Format)) == ERR_NONE && !Format)
p->TitleTime = -1;
p->Player->Get(p->Player,PLAYER_TITLE,TitleName,sizeof(TitleName));
if (tcscmp(p->TitleName,TitleName)!=0)
{
tcscpy_s(p->TitleName,TSIZEOF(p->TitleName),TitleName);
GetTextExtentPoint(Paint.hdc,p->TitleName,tcslen(p->TitleName),&Size);
p->TitleNameWidth = Size.cx;
p->TitleNameOffset = 0;
p->ScrollMode = 0;
p->UpdateScroll = 1;
}
s = Dur;
Dur[0] = 0;
if (p->Player->Get(p->Player,PLAYER_DURATION,&Duration,sizeof(Duration)) == ERR_NONE && Duration>=0)
{
TickToString(Dur,TSIZEOF(Dur),Duration,0,0,1);
if (p->TitleTime<0)
p->TitleTime = 0;
}
else
s = T("0:00:00");
GetTextExtentPoint(Paint.hdc,s,tcslen(s),&Size);
p->TitleTimeWidth = Size.cx;
p->TitleDurWidth = 0;
p->TitleDur[0] = 0;
if (Dur[0])
{
stprintf_s(p->TitleDur,TSIZEOF(p->TitleDur),T("/%s"),Dur);
GetTextExtentPoint(Paint.hdc,p->TitleDur,tcslen(p->TitleDur),&Size);
p->TitleDurWidth = Size.cx;
p->UpdateScroll = 1;
}
}
if (p->TitleTime>=0)
TickToString(Time,TSIZEOF(Time),p->TitleTime,0,0,1);
else
Time[0] = 0;
r.top = p->TitleTop;
r.bottom = p->TitleHeight - p->TitleTop;
r.left = p->TitleBorder;
r.right = p->TitleWidth - p->TitleTimeWidth - p->TitleDurWidth - p->TitleBorder * 2;
p->TitleNameSize = r.right - r.left;
if (p->UpdateScroll)
{
p->UpdateScroll = 0;
UpdateTitleScroll(p);
}
ExtTextOut(Paint.hdc,r.left-p->TitleNameOffset,r.top,ETO_CLIPPED,&r,p->TitleName,tcslen(p->TitleName),NULL);
r.left = r.right + p->TitleBorder;
r.right = r.left + p->TitleTimeWidth;
//SetBkColor(Paint.hdc,0xFFFFFF);
ExtTextOut(Paint.hdc,r.left,r.top,ETO_CLIPPED|ETO_OPAQUE,&r,Time,tcslen(Time),NULL);
//SetBkColor(Paint.hdc,0x00FF00);
if (p->TitleDurWidth)
{
r.left = r.right;
r.right = r.left + p->TitleDurWidth;
ExtTextOut(Paint.hdc,r.left,r.top,ETO_CLIPPED,&r,p->TitleDur,tcslen(p->TitleDur),NULL);
}
EndPaint(WndTitle,&Paint);
break;
}
}
return DefWindowProc(WndTitle,Msg,wParam,lParam);
}
static void SetKeyInSeek(intface* p)
{
bool_t First = !p->InSeek;
p->InSeek = 1;
p->Player->Set(p->Player,PLAYER_INSEEK,&p->InSeek,sizeof(p->InSeek));
SetTimer(p->Win.Wnd,TIMER_KEYINSEEK,First?KEYINSEEK_START:KEYINSEEK_REPEAT,NULL);
}
static void StopSeek(intface* p)
{
p->InSeek = 0;
p->Player->Set(p->Player,PLAYER_INSEEK,&p->InSeek,sizeof(p->InSeek));
KillTimer(p->Win.Wnd,TIMER_KEYINSEEK);
if (p->Capture)
{
ReleaseCapture();
p->Capture = 0;
KillTimer(p->Win.Wnd,TIMER_SLIDERINSEEK);
}
}
LRESULT CALLBACK TrackProc(HWND WndTrack, UINT Msg, WPARAM wParam, LPARAM lParam)
{
intface* p = (intface*) WinGetObject(WndTrack);
if (Msg == WM_LBUTTONDOWN)
{
p->InSeek = 1;
p->Capture = 1;
p->TrackSetPos = -1;
p->Player->Set(p->Player,PLAYER_INSEEK,&p->InSeek,sizeof(p->InSeek));
SetTrackPos(p,LOWORD(lParam));
SetCapture(WndTrack);
SetTimer(p->Win.Wnd,TIMER_SLIDERINSEEK,SLIDERINSEEK_CYCLE,NULL);
return 0;
}
if (Msg == WM_MOUSEMOVE)
{
if (p->InSeek && (wParam & MK_LBUTTON))
SetTrackPos(p,LOWORD(lParam));
return 0;
}
if (Msg == WM_LBUTTONUP)
{
if (p->InSeek)
{
SetTrackPos(p,LOWORD(lParam));
StopSeek(p);
}
return 0;
}
return CallWindowProc(p->DefTrackProc,WndTrack,Msg,wParam,lParam);
}
void UpdateVol(intface* p)
{
if (p->Vol >= 0)
{
SendMessage(p->WndVol,TBM_SETPOS,1,p->Vol);
p->Player->Set(p->Player,PLAYER_VOLUME,&p->Vol,sizeof(p->Vol));
p->Vol = -1;
if (p->Skin[p->SkinNo].Valid)
SkinUpdate(&p->Skin[p->SkinNo],p->Player,p->Win.Wnd,&p->SkinArea);
}
}
void SetVolPos(intface* p,int x)
{
RECT r;
int Adj;
SendMessage(p->WndVol,TBM_GETCHANNELRECT,0,(LONG)&r);
Adj = WinUnitToPixelX(&p->Win,VOLTHUMB)/4;
r.left += Adj;
r.right -= Adj;
if (x > 32768) x -= 65536;
if (r.right <= r.left) r.right = r.left+1;
if (x < r.left) x = r.left;
if (x > r.right) x = r.right;
p->Vol = (100*(x-r.left))/(r.right-r.left);
}
LRESULT CALLBACK VolBackProc(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
//DEBUG_MSG1(DEBUG_WIN,T("MSG %04x"),Msg);
switch (Msg)
{
#if defined(TARGET_WINCE)
case WM_CTLCOLORSTATIC:
return (LRESULT) GetSysColorBrush(COLOR_BTNFACE);
#endif
}
return DefWindowProc(Wnd,Msg,wParam,lParam);
}
LRESULT CALLBACK VolProc(HWND WndVol, UINT Msg, WPARAM wParam, LPARAM lParam)
{
intface* p = (intface*) WinGetObject(WndVol);
switch (Msg)
{
case WM_MOUSEMOVE:
if ((wParam & MK_LBUTTON)==0)
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
SetVolPos(p,LOWORD(lParam));
if (!p->InVol)
{
p->InVol = 1;
SetForegroundWindow(p->Win.Wnd);
SetCapture(WndVol);
SetTimer(p->Win.Wnd,TIMER_SLIDERINVOL,SLIDERINVOL_CYCLE,NULL);
UpdateVol(p);
}
return 0;
case WM_LBUTTONUP:
if (!p->InVol)
SetForegroundWindow(p->Win.Wnd);
else
{
p->InVol = 0;
ReleaseCapture();
KillTimer(p->Win.Wnd,TIMER_SLIDERINVOL);
}
SetVolPos(p,LOWORD(lParam));
UpdateVol(p);
return 0;
}
return CallWindowProc(p->DefVolProc,WndVol,Msg,wParam,lParam);
}
void CreateDeviceMenu(intface* p)
{
int No;
int *i;
NodeEnumClass(&p->VOutput,VOUT_CLASS);
NodeEnumClass(&p->AOutput,AOUT_CLASS);
for (No=0,i=ARRAYBEGIN(p->VOutput,int);i!=ARRAYEND(p->VOutput,int);++i,++No)
{
if (VOutIDCT(*i))
{
tchar_t s[256];
stprintf_s(s,TSIZEOF(s),LangStr(INTERFACE_ID,IF_OPTIONS_VIDEO_ACCEL),LangStr(*i,NODE_NAME));
WinMenuInsert(&p->Win,1,IF_OPTIONS_VIDEO_TURNOFF,IF_VIDEOACCEL+No,s);
}
WinMenuInsert(&p->Win,1,IF_OPTIONS_VIDEO_TURNOFF,IF_VIDEO+No,LangStr(*i,NODE_NAME));
}
for (No=0,i=ARRAYBEGIN(p->AOutput,int);i!=ARRAYEND(p->AOutput,int);++i,++No)
WinMenuInsert(&p->Win,1,IF_OPTIONS_AUDIO_TURNOFF,IF_AUDIO+No,LangStr(*i,NODE_NAME));
}
static menudef MenuDef[] =
{
{ 0,INTERFACE_ID, IF_FILE },
{ 1,INTERFACE_ID, IF_FILE_OPENFILE },
{ 1,INTERFACE_ID, IF_FILE_CORETHEQUE },
{ 1,INTERFACE_ID, IF_FILE_PLAYLIST },
{ 1,-1,-1 },
{ 1,INTERFACE_ID, IF_PLAY },
{ 1,INTERFACE_ID, IF_NEXT },
{ 1,INTERFACE_ID, IF_PREV },
{ 1,-1,-1 },
{ 1,INTERFACE_ID, IF_FILE_CHAPTERS },
{ 2,INTERFACE_ID, IF_FILE_CHAPTERS_NONE },
{ 1,INTERFACE_ID, IF_FILE_MEDIAINFO },
{ 1,INTERFACE_ID, IF_FILE_BENCHMARK },
{ 1,INTERFACE_ID, IF_FILE_ABOUT },
{ 1,-1,-1 },
{ 1,INTERFACE_ID, IF_FILE_EXIT },
{ 0,INTERFACE_ID, IF_OPTIONS },
{ 1,INTERFACE_ID, IF_OPTIONS_SPEED },
{ 2,INTERFACE_ID, IF_OPTIONS_SPEED_10 },
{ 2,INTERFACE_ID, IF_OPTIONS_SPEED_25 },
{ 2,INTERFACE_ID, IF_OPTIONS_SPEED_50 },
{ 2,INTERFACE_ID, IF_OPTIONS_SPEED_80 },
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -