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

📄 osmo4.cpp

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}	return TRUE;}/////////////////////////////////////////////////////////////////////////////// COsmo4 message handlers/////////////////////////////////////////////////////////////////////////////// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog{public:	CAboutDlg();// Dialog Data	//{{AFX_DATA(CAboutDlg)	enum { IDD = IDD_ABOUTBOX };	CStatic m_AbtTxt;	//}}AFX_DATA	// ClassWizard generated virtual function overrides	//{{AFX_VIRTUAL(CAboutDlg)	protected:	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support	//}}AFX_VIRTUAL// Implementationprotected:	//{{AFX_MSG(CAboutDlg)	virtual BOOL OnInitDialog();		// Added for WCE apps	//}}AFX_MSG	DECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD){	//{{AFX_DATA_INIT(CAboutDlg)	//}}AFX_DATA_INIT}void CAboutDlg::DoDataExchange(CDataExchange* pDX){	CDialog::DoDataExchange(pDX);	//{{AFX_DATA_MAP(CAboutDlg)	DDX_Control(pDX, IDC_ABT_TEXT, m_AbtTxt);	//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)	//{{AFX_MSG_MAP(CAboutDlg)		// No message handlers	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// COsmo4 commands// Added for WCE appsBOOL CAboutDlg::OnInitDialog() {	CDialog::OnInitDialog();	CString str = _T("Osmo4 Player\nGPAC V");	str += _T(GPAC_VERSION);	m_AbtTxt.SetWindowText(str);	return TRUE; }void COsmo4::OnAppAbout(){	CAboutDlg aboutDlg;	ShowTaskBar(1);	aboutDlg.DoModal();	ShowTaskBar(0);}int COsmo4::ExitInstance() {	gf_term_del(m_term);	gf_modules_del(m_user.modules);	gf_cfg_del(m_user.config);	ShowTaskBar(1);	gf_sys_close();	if (m_logs) fclose(m_logs);	return CWinApp::ExitInstance();}void COsmo4::SetOptions(){	const char *sOpt = gf_cfg_get_key(m_user.config, "General", "Loop");	m_Loop = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0;	sOpt = gf_cfg_get_key(m_user.config, "General", "FillScreen");	m_fit_screen = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0;	sOpt = gf_cfg_get_key(m_user.config, "General", "DisableBackLight");	m_disable_backlight = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0;	gf_term_set_option(m_term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);	sOpt = gf_cfg_get_key(m_user.config, "General", "NoMIMETypeFetch");	m_no_mime_fetch = (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0;	//gf_term_set_option(m_term, GF_OPT_AUDIO_VOLUME, 100);}void COsmo4::Pause(){	if (!m_open) return;	if (gf_term_get_option(m_term, GF_OPT_PLAY_STATE)==GF_STATE_PLAYING) {		gf_term_set_option(m_term, GF_OPT_PLAY_STATE, GF_STATE_PAUSED);		SetBacklightState(0);	} else {		gf_term_set_option(m_term, GF_OPT_PLAY_STATE, GF_STATE_PLAYING);		SetBacklightState(1);	}	((CMainFrame*)m_pMainWnd)->SetPauseButton();}void COsmo4::ReloadTerminal(){	Bool reconnect = m_open;	m_reconnect_time = 0;	if (m_can_seek) m_reconnect_time = gf_term_get_time_in_ms(m_term);	gf_term_del(m_term);	m_term = gf_term_new(&m_user);	if (!m_term) {		MessageBox(NULL, _T("Fatal Error !!"), _T("Couldn't change renderer"), MB_OK);		m_pMainWnd->PostMessage(WM_DESTROY);		return;	}	if (reconnect) m_pMainWnd->PostMessage(WM_OPENURL);}void COsmo4::OnConfigure(){	COptions dlg;		ShowTaskBar(1);	dlg.DoModal();	ShowTaskBar(0);	if (dlg.m_bNeedsReload) ReloadTerminal();}void COsmo4::ShowTaskBar(Bool showIt, Bool pause_only){	if (showIt) {		m_DoResume = 0;		if (gf_term_get_option(m_term, GF_OPT_PLAY_STATE)==GF_STATE_PLAYING) {			m_DoResume = 1;			gf_term_set_option(m_term, GF_OPT_PLAY_STATE, GF_STATE_PAUSED);		}		gf_term_set_option(m_term, GF_OPT_FREEZE_DISPLAY, 1);		if (!pause_only) {			SHFullScreen(GetForegroundWindow(), SHFS_HIDESTARTICON | SHFS_SHOWTASKBAR| SHFS_SHOWSIPBUTTON);			::ShowWindow(::FindWindow(_T("HHTaskbar"),NULL), SW_SHOWNA);		}		SetBacklightState(0);	} else {		if (!pause_only) {			SHFullScreen(GetForegroundWindow(), SHFS_HIDESTARTICON | SHFS_HIDETASKBAR| SHFS_HIDESIPBUTTON);			::ShowWindow(::FindWindow(_T("HHTaskbar"),NULL), SW_HIDE);		}		gf_term_set_option(m_term, GF_OPT_FREEZE_DISPLAY, 0);		gf_term_set_option(m_term, GF_OPT_REFRESH, 0);		if (m_DoResume) {			gf_term_set_option(m_term, GF_OPT_PLAY_STATE, GF_STATE_PLAYING);			SetBacklightState(1);			m_DoResume = 0;		}		m_pMainWnd->SetFocus();	}}CString COsmo4::GetFileFilter(){	u32 keyCount, i;	CString sFiles;	CString sExts;	CString supportedFiles;	return CString("All Files |*.*|");	supportedFiles = "All Known Files|*.m3u;*.pls";	sExts = "";	sFiles = "";	keyCount = gf_cfg_get_key_count(m_user.config, "MimeTypes");	for (i=0; i<keyCount; i++) {		const char *sMime;		Bool first;		char *sKey;		char szKeyList[1000], sDesc[1000];		short swKeyList[1000], swDesc[1000];		sMime = gf_cfg_get_key_name(m_user.config, "MimeTypes", i);		if (!sMime) continue;		CString sOpt;		const char *opt = gf_cfg_get_key(m_user.config, "MimeTypes", sMime);		/*remove #include <gpac/options.h> name*/		strcpy(szKeyList, opt+1);		sKey = strrchr(szKeyList, '\"');		if (!sKey) continue;		sKey[0] = 0;		/*get description*/		sKey = strrchr(szKeyList, '\"');		if (!sKey) continue;		strcpy(sDesc, sKey+1);		sKey[0] = 0;		sKey = strrchr(szKeyList, '\"');		if (!sKey) continue;		sKey[0] = 0;		CE_CharToWide(sDesc, (unsigned short *)swDesc);		CE_CharToWide(szKeyList, (unsigned short *)swKeyList);		/*if same description for # mime types skip (means an old mime syntax)*/		if (sFiles.Find((LPCTSTR) swDesc)>=0) continue;		/*if same extensions for # mime types skip (don't polluate the file list)*/		if (sExts.Find((LPCTSTR) swKeyList)>=0) continue;		sExts += (LPCTSTR) swKeyList;		sExts += " ";		sFiles += (LPCTSTR) swDesc;		sFiles += "|";		first = 1;		sOpt = CString(szKeyList);		while (1) {						int pos = sOpt.Find(' ');			CString ext = (pos==-1) ? sOpt : sOpt.Left(pos);			/*WATCHOUT: we do have some "double" ext , eg .wrl.gz - these are NOT supported by windows*/			if (ext.Find(_T("."))<0) {				if (!first) {					sFiles += ";";				} else {					first = 0;				}				sFiles += "*.";				sFiles += ext;				CString sext = ext;				sext += ";";				if (supportedFiles.Find(sext)<0) {					supportedFiles += ";*.";					supportedFiles += ext;				}			}			if (sOpt==ext) break;			CString rem;			rem.Format(_T("%s "), (LPCTSTR) ext);			sOpt.Replace((LPCTSTR) rem, _T(""));		}		sFiles += "|";	}	supportedFiles += "|";	supportedFiles += sFiles;	//supportedFiles += "M3U Playlists|*.m3u|ShoutCast Playlists|*.pls|All Files |*.*|";	supportedFiles += "All Files |*.*|";	return supportedFiles;}void COsmo4::OnOpenFile() {	Bool res;	CFileDialog fd(TRUE,NULL,_T("\\"),OFN_HIDEREADONLY, GetFileFilter());	ShowTaskBar(1);	res = 0;	if (fd.DoModal()==IDOK) {		res = 1;		m_filename = fd.GetPathName();		m_DoResume = 0;/*done by term*/	} 	ShowTaskBar(0);	if (res) m_pMainWnd->PostMessage(WM_OPENURL);}void COsmo4::OnOpenUrl() {	OpenDlg dlg;	Bool res;	ShowTaskBar(1, 1);	res = 0;	if (dlg.DoModal() == IDOK) {		res = 1;		m_DoResume = 0;/*done by term*/	} 	ShowTaskBar(0, 1);	if (res) m_pMainWnd->PostMessage(WM_OPENURL);}void COsmo4::SetBacklightState(Bool disable) {	HKEY hKey = 0;	DWORD dwSize;	DWORD dwValue;	HANDLE hBL;	if (!m_disable_backlight) return;	if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("ControlPanel\\Backlight"), 0, 0, &hKey ) != ERROR_SUCCESS) return;	if (disable) {		dwSize = 4;		RegQueryValueEx(hKey, _T("BatteryTimeout"), NULL, NULL,(unsigned char*) &m_prev_batt_bl, &dwSize);		dwSize = 4;		RegQueryValueEx(hKey, _T("ACTimeout"), NULL, NULL, (unsigned char*) &m_prev_ac_bl,&dwSize);		dwSize = 4;		dwValue = 0xefff ;		RegSetValueEx(hKey, _T("BatteryTimeout"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize);		dwSize = 4;		dwValue = 0xefff ;		RegSetValueEx( hKey, _T("ACTimeout"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize);	} else {		if (m_prev_batt_bl) {			dwSize = 4;			RegSetValueEx(hKey, _T("BatteryTimeout"), NULL, REG_DWORD, (unsigned char *)&m_prev_batt_bl, dwSize);		}		if (m_prev_ac_bl) {			dwSize = 4;			RegSetValueEx(hKey, _T("ACTimeout"), NULL, REG_DWORD,(unsigned char *)&m_prev_ac_bl, dwSize);		}	}	RegCloseKey(hKey);	hBL = CreateEvent(NULL, FALSE, FALSE, _T("BackLightChangeEvent"));	if (hBL) {		SetEvent(hBL);		CloseHandle(hBL);	}}void COsmo4::OnShortcuts() {	ShowTaskBar(1);	MessageBox(NULL,		_T("Double Click: Fullscreen on/off\n"),		_T("Osmo4 Shortcuts"),		MB_OK);		ShowTaskBar(0);}

⌨️ 快捷键说明

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