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

📄 pocketmvp.cpp

📁 PocketMVP V0.8082503 source for Pocket 的程序源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			if (DrawHeight>=VisibleHeight) sY=0;
			NeedHide=true;
			if (!bPaused)
			{
				ShowControls(false);
			}
#ifdef ATI
		}
#endif
	}
	else
	{

#ifdef IPAQ
		if (!g_bInvert)
			sX=PlayerSkin.ViewPort.top+PlayerSkin.ViewPort.height-(PlayerSkin.ViewPort.height-DrawWidth)/2;
		else
			sX=PlayerSkin.ViewPort.top+(PlayerSkin.ViewPort.height-DrawWidth)/2;
		sY=PlayerSkin.ViewPort.left+(PlayerSkin.ViewPort.width-DrawHeight)/2;
		if (!g_bInvert) sX=VisibleWidth-sX-26;
		else sX+=26;
#else
		sY=PlayerSkin.ViewPort.top+(PlayerSkin.ViewPort.height-DrawHeight)/2;
		sX=PlayerSkin.ViewPort.left+(PlayerSkin.ViewPort.width-DrawWidth)/2;
#if (_WIN32_WCE >= 300 && !defined(HPC))
		sY+=26;
#endif
#endif
		if (sY<0) sY=0;
		if (sX<0) sX=0;
		if (sX%2) sX++;
		if (sY%2) sY++;
	}
#ifdef ATI
	if (nWidth&&(nHeight)) SetupATIOverlay(nWidth,nHeight);
#endif

#ifdef _USEVIDBUFF
	nExtra=DisplayWidth-nWidth;
	vbuffStart=(unsigned char*)(vbuff+(sY*DisplayWidth)+sX);
#else
#ifdef GAPI
	nExtra=DisplayWidth-nWidth;
#ifdef MIPS
	GXSetViewport( sY, DrawHeight, NULL, NULL );
#endif
#else
	nExtra=0;
	vbuffStart=(unsigned char*)outputBuffer;
#endif
#endif

	StartPos=((sY*DisplayWidth)+sX);

}

void ResetDisplay(HWND hWnd)
{
	if (!tot)
	{
		return;
	}
	short nWidth=g_nWidth;
	short nHeight=g_nHeight;
	int size,frame;
	int decoded=0;
	decBegin(2);
	do
	{
		unsigned char* rb=(unsigned char*)GetNextBuffer(&size,&frame,0);
		if (!rb)
		{
			continue;
		}
#ifdef IPAQ
		decoded=Decode(rb,frame,(unsigned char*) outputBuffer,2,-1,1);
#else
#ifdef ARM
		decoded=Decode(rb,frame,(unsigned char*) outputBuffer,2,-1,1);
#else
		decoded=Decode(rb,frame,(unsigned char*) outputBuffer,2,0);
#endif
#endif
		nCurrentFrame++;
	}while(!decoded);
	if (hb)
	{
		DeleteObject(hb);
		hb=NULL;
	}
#ifndef IPAQ
	if (PlayerOptions.Rotate)
#else
	if (!PlayerOptions.Rotate)
#endif

	{
		nWidth=g_nHeight;
		nHeight=g_nWidth;
	}
#ifndef IPAQ
	if (nWidth>VisibleWidth) nWidth=VisibleWidth;
	if (nHeight>VisibleHeight) nHeight=VisibleHeight;
#else
	if (nHeight>VisibleWidth) nHeight=VisibleWidth;
	if (nWidth>VisibleHeight) nWidth=VisibleHeight;
#endif
	hb=CreateBitmap(nWidth,nHeight,1,COLORDEPTH,outputBuffer);
	decBegin(-1);
	RefreshDisplay(false);
}


void OptionRefresh(HWND hWnd,bool* option)
{
	if (ptid&&(vidinfo->video_frames))
	{
		if (!bPaused)
		{
			Pause();
			if (option) *option=!*option;
			RecalculateDimensions(hWnd);	
			decBegin(2);
			decBegin(-1);
			Pause();
		}
		else
		{
			if (option) *option=!*option;
			RecalculateDimensions(hWnd);	
			ResetDisplay(hWnd);
#ifdef MIPS
			RefreshDisplay(true);
#endif
		}
	}
	else
	{
		if (option) *option=!*option;
	}
}



/*****************************************************************************************/
//Plugin Control Functions
/*****************************************************************************************/

int LoadDecoder()
{
	HKEY hKey = 0;
	DWORD dwSize = 0;
	DWORD dwType = 0;
	DWORD dwTmp;
	TCHAR temp[10];
	TCHAR value[200];
	int n=0;
	if (hdivx) FreeLibrary((HINSTANCE)hdivx);
	if (ha) FreeLibrary((HINSTANCE)ha);
	hdivx=NULL;
	ha=NULL;
	DropTwo=1;
	if (vidinfo->a_fmt>1)
	{
		RawAudio=false;
		if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_AUDIO, 0, 0, &hKey ) )
		{
			dwTmp = 0;
			wcscpy(temp,_T(""));
			dwSize =sizeof(value);
			TCHAR fmt[10];
			_itow(vidinfo->a_fmt,fmt,10);
			wcscat(temp,fmt);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					ha=LoadLibrary(value);
					if (!ha)
					{
						return -1;
					}		
				}
				else
				{
					ha=NULL;
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file contains an incompatible audio format"),_T("Audio Error"),MB_OK);
				vidinfo->audio_bytes = 0;
//				return -1;
			}
			RegCloseKey( hKey );
		}
		else
		{
			MessageBox(hWndMain,_T("This file contains an incompatible audio format"),_T("Audio Error"),MB_OK);
			vidinfo->audio_bytes = 0;
		}
	}	
	else
	{
		RawAudio=true;
	}
	if (strcmp(vidinfo->compressor,""))
	{
		if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_VIDEO, 0, 0, &hKey ) )
		{
			dwTmp = 0;
			wcscpy(temp,_T(""));
			dwSize =sizeof(value);
			TCHAR hold[5];
			MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,vidinfo->compressor,-1,hold,5);
			wcslwr(hold);
			wcscat(temp,hold);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					hdivx=LoadLibrary(value);
					if (!hdivx)
					{
						return -1;
					}		
					DecodeMessage=(pdecode_msg)GetProcAddress((HINSTANCE)hdivx,_T("DecodeInit"));
					DecodeFrame=(pdecode_frame)GetProcAddress((HINSTANCE)hdivx,_T("DecodeFrame"));
				}
				else
				{
					hdivx=NULL;
					DropTwo=0;
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file contains an incompatible video format 1"),_T("Video Error"),MB_OK);
				vidinfo->video_frames = 0;
			}
			RegCloseKey( hKey );
		}
		else
		{
				MessageBox(hWndMain,_T("This file contains an incompatible video format 2"),_T("Video Error"),MB_OK);
				vidinfo->video_frames = 0;
		}
	}	
	if (vidinfo->video_frames==0&&(vidinfo->audio_bytes==0))
		return -1;
	if (hdivx==NULL)
	{
		DecodeMessage=(pdecode_msg)dummy_decore; 
		DecodeFrame=(pdecode_frame)dummy_decore_frame;
	}

	return 0;
}
int LoadReader()
{
	static HANDLE hmp3=NULL;
	HKEY hKey = 0;
	DWORD dwSize = 0;
	DWORD dwType = 0;
	DWORD dwTmp;
	TCHAR temp[10];
	TCHAR value[200];


	NoIndex=0;
	if (hmp3)
	{
		FreeLibrary((HINSTANCE)hmp3);
		hmp3=NULL;
	}
	GetFileExt(FileName,temp);
	if (!wcscmp(FileName,_T("Broadcast")))
	{
		hmp3=LoadLibrary(_T("BroadcastReader.dll"));
	}
	else if (wcsstr(FileName,_T(".avi"))||(wcsstr(FileName,_T(".AVI")))||(wcsstr(FileName,_T(".divx"))||(wcsstr(FileName,_T(".DIVX")))))
	{
		if (Stream||(PlayerOptions.NoIndex))
		{
			hmp3=LoadLibrary(_T("avistream.dll"));
			NoIndex=1;
		}
		else
		{
			READER_InitializeReader=InitializeReader;
			READER_InitializeReader(&rd);
			return 0;
		}
	}
	else if ( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_BASE_FMT, 0, 0, &hKey ) )
	{
			dwTmp = 0;
			dwSize =sizeof(value);
			wcslwr(temp);
			if ( ERROR_SUCCESS == RegQueryValueEx( hKey, temp, 0, &dwType, ( LPBYTE )value, &dwSize ) )
			{
				if (wcsicmp(value,_T("")))
				{
					hmp3=LoadLibrary(value);
				}
				else
				{
					hmp3=NULL;
					RegCloseKey( hKey );
				}
			}
			else
			{
				MessageBox(hWndMain,_T("This file is of an unknown format"),_T("Video Error"),MB_OK);
				return -1;
			}
			RegCloseKey( hKey );
	}
	else
	{
			MessageBox(hWndMain,_T("This file is of an unknown format"),_T("Video Error"),MB_OK);
			return -1;
	}
	
	
	
	
	
	if (hmp3!=NULL)
	{
		READER_InitializeReader=(pInitializeReader) GetProcAddress((HINSTANCE)hmp3,_T("InitializeReader"));
		READER_InitializeReader(&rd);
		return 0;
	}
	else
	{
		LPVOID lpMsgBuf;
		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,NULL,GetLastError(),0,(LPTSTR) &lpMsgBuf, 0, NULL );
		MessageBox( NULL, (LPCTSTR)lpMsgBuf, _T("Error loading file reader"), MB_OK | MB_ICONINFORMATION );
		LocalFree( lpMsgBuf );
		return -1;
	}
}

/*****************************************************************************************/
//Player Control Functions
/*****************************************************************************************/


void StopFastForward()
{
	FastForward=!FastForward;
	tot=vidinfo->video_frames-vidinfo->video_pos;
	nCurrentFrame=0;
	baseTick=0;
	if (!NeedHide) DrawButtonUp(&PlayerSkin.FFWDButton);
	else
		PlayerSkin.FFWDButton.status=0;
	if (PlayerOptions.Audio&&(vidinfo->audio_bytes))
	{
		totAudio=rd.READER_ReSeekAudio();

		Exit();
		Init(PlayerOptions.EnableEQ,0);
		waveOutReset(m_hwo);
	}
}



void Pause()
{
	if (!bPaused)
	{
		bPaused=!bPaused;
		if (PlayerOptions.Audio) waveOutPause(m_hwo);
		while((nShouldbe)&&(nCurrentFrame<=nShouldbe+1)) Sleep(1);
		EnterCriticalSection(&cs);
		LeaveCriticalSection(&cs);
		//Sleep(500);
		if (!PlayerSkin.FFWDButton.status)
		{
			ResetDisplay(hWndMain);
			if (NeedHide) ShowControls(true);
		}
#if (_WIN32_WCE >= 300)
		if (PlayerOptions.KeepAlive) RegOptionBLTimeout( false );
#endif
	}
	else
	{
		lastshow=0;
		Display=2;
		if (!PlayerOptions.Audio||(vidinfo->audio_bytes<=0))
		{
			baseTick=MyGetTickCount();
			tot=tot-nCurrentFrame;
			nCurrentFrame=1;
		}
		totMsTime=(int)(((double)(tot*1000))/vidinfo->fps);
		if (PlayerOptions.Audio) waveOutRestart(m_hwo);
		bPaused=!bPaused;
#if (_WIN32_WCE >= 300)
		if (PlayerOptions.KeepAlive) RegOptionBLTimeout( true );

#endif
		if (NeedHide)
		{
			ShowControls(false);
		}

	}

}
void DrawInfoView(HDC hdc, bool scroll);
void ChangeView()
{
	if ((vidinfo)&&(!vidinfo->video_frames))	
	{
		if (MaxFile&&(PlayerOptions.Playlist)&&(PlayerOptions.Media))
		{
			RECT rc;
			ShowWindow(hwndID3,SW_SHOWNORMAL);
			ShowWindow(hwndList,SW_SHOWNORMAL);
			ListView_SetItemState(hwndList,CurrentFile,LVIS_SELECTED|LVIS_FOCUSED,0xFFFF);
			ListView_EnsureVisible( hwndList, CurrentFile, false );
			MoveWindow(hwndList,PlayerSkin.ViewPort.left , PlayerSkin.ViewPort.top, PlayerSkin.ViewPort.width, PlayerSkin.ViewPort.height/3,true);
			GetClientRect(hwndList,&rc);
			MoveWindow(hwndID3,PlayerSkin.ViewPort.left , PlayerSkin.ViewPort.top+rc.bottom+5, PlayerSkin.ViewPort.width, PlayerSkin.ViewPort.height-rc.bottom-5,true);
		}
		else if (MaxFile&&(PlayerOptions.Playlist))
		{
			ShowWindow(hwndID3,SW_HIDE);
			ShowWindow(hwndList,SW_SHOWNORMAL);
			ListView_SetItemState(hwndList,CurrentFile,LVIS_SELECTED|LVIS_FOCUSED,0xFFFF);
			ListView_EnsureVisible( hwndList, CurrentFile, false );
			MoveWindow(hwndList,PlayerSkin.ViewPort.left , PlayerSkin.ViewPort.top, PlayerSkin.ViewPort.width, PlayerSkin.ViewPort.height,true);
		}
		else if (PlayerOptions.Media)
		{
			ShowWindow(hwndList,SW_HIDE);
			ShowWindow(hwndID3,SW_SHOWNORMAL);
			MoveWindow(hwndID3,PlayerSkin.Vi

⌨️ 快捷键说明

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