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

📄 oggplay.cpp

📁 OggPlay for Symbian 是symbian上的一个媒体播放程序的源码。它支持ogg,wav等等多媒体格式。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#if defined(SERIES60)
	TRAPD(err, iStartUpErrorDlg->ExecuteLD(errorTxt));
	iStartUpErrorDlg = NULL;
#else
	TRAPD(err, iEikonEnv->InfoWinL(iStartUpErrorTxt1, errorTxt));
#endif

	Exit();
}

void COggPlayAppUi::StartOggPlayL()
{
	TFileName fileName(Application()->AppFullName());
	TParsePtr parse(fileName);

#if defined(SERIES60V3)
	TFileName privatePath;
	User::LeaveIfError(iCoeEnv->FsSession().PrivatePath(privatePath));

	iIniFileName.Copy(parse.Drive());
	iIniFileName.Append(privatePath);
	iIniFileName.Append(_L("OggPlay.ini"));
 
	iDbFileName.Copy(parse.Drive());
	iDbFileName.Append(privatePath);
	iDbFileName.Append(_L("OggPlay.db"));

	iSkinFileDir.Copy(parse.Drive());
	iSkinFileDir.Append(privatePath);
	iSkinFileDir.Append(_L("import\\"));
#else
	iIniFileName.Copy(fileName);
	iIniFileName.SetLength(iIniFileName.Length() - 3);
	iIniFileName.Append(_L("ini"));

	iDbFileName.Copy(fileName);
	iDbFileName.SetLength(iDbFileName.Length() - 3);
	iDbFileName.Append(_L("db"));

	iSkinFileDir.Copy(parse.DriveAndPath());
#endif

#if defined(__WINS__)
	// The emulator doesn't like to write to the Z: drive, avoid that.
	iIniFileName = _L("C:\\oggplay.ini");
	iDbFileName = _L("C:\\oggplay.db");
#endif

	iSkins= new(ELeave) CDesCArrayFlat(3);
	FindSkins();
	
	iOggMsgEnv = new(ELeave) COggMsgEnv(iSettings);

#ifdef PLUGIN_SYSTEM
	iOggPlayback= new(ELeave) COggPluginAdaptor(iOggMsgEnv, this);
#else
	iOggPlayback= new(ELeave) COggPlayback(iOggMsgEnv, this);
#endif

	iOggPlayback->ConstructL();

	ReadIniFile();

 	iAppView = new(ELeave) COggPlayAppView();
	iAppView->ConstructL(this, ClientRect());

	SetRandomL(iSettings.iRandom);
	SetRepeat(iSettings.iRepeat);

	HandleCommandL(EOggSkinOne+iCurrentSkin);
	
	AddToStackL(iAppView); // Receiving Keyboard Events 
	iAppView->InitView();

	SetHotKey();

#ifdef MONITOR_TELEPHONE_LINE
	iActive= new (ELeave) COggActive();
	iActive->ConstructL(this);
	iActive->IssueRequest();
#endif

#if defined(MULTI_THREAD_PLAYBACK)
	// Resist any attempts by the OS to give us anything other than foreground priority
	// Disable process priority changes
	CEikonEnv::Static()->WsSession().ComputeMode(RWsSession::EPriorityControlDisabled);

	// Change the process priority to EPriorityForeground
	RProcess process;
	process.SetPriority(EPriorityForeground);

#else
	SetProcessPriority();
	SetThreadPriority();
#endif
}

void COggPlayAppUi::PostConstruct()
{
	TRAPD(err, PostConstructL());
	NextStartUpState(err);
}

void COggPlayAppUi::PostConstructL()
{
	// Ideally we just de-register (and delete) the splash view now that we are done with it. 
	// However, on S60 V1 we can't do this if OggPlay is running embedded: for some reason we get a CONE 30 panic
	// if the apps key is pressed (the app that embeds us must try to access the splash view I guess)
	// Similarly S90 doesn't like us de-registering the splash view either :-(
#if !defined(SERIES90)
	if (!iIsRunningEmbedded)
	{
		// Delete the splash view. We won't be seeing it again
		DeregisterView(*iSplashFOView);

		delete iSplashFOView;
		iSplashFOView = NULL;
	}
#endif

#if defined(UIQ) && !defined(MOTOROLA)
	// In FC mode the splash view is also used to launch
	// the main FC view, so we can't de-register it here, :-(
	// DeregisterView(*iSplashFCView);

	// delete iSplashFCView;
	// iSplashFCView = NULL;
#endif

	if (iSettings.iAutoplay && !iIsRunningEmbedded)
	{
		// Restore the view
		for(TInt i=0;i<iRestoreStack.Count();i++)
		{
			iAppView->SelectItem(iRestoreStack[i]);
			HandleCommandL(EOggPlay);
		}

		iAppView->SelectItem(iRestoreCurrent);

		// Start playing
		NextSong();
	}
	else if (iIsRunningEmbedded)
	{
		if (iAppView->iOggFiles->CreateDbWithSingleFile(iEmbeddedFileName))
		{
			// No repeat when running in embedded mode, override the default iSettings.iRepeat
			iSongList->SetRepeat(EFalse);

			// Start playing
			NextSong();
		}
		else
			iIsRunningEmbedded = EFalse;
	}

	// Restart display updates
	iAppView->RestartCallBack();

	// Initialise the alarm
	iAppView->SetAlarm();
}

COggPlayAppUi::~COggPlayAppUi()
{
	if (iDoorObserver)
		iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::ENoChanges); 

	if (iStartUpAO)
		iStartUpAO->Cancel();
	delete iStartUpAO;

#if defined (SERIES60)
	delete iStartUpErrorDlg;
#endif

	if (iSplashFOView)
	{
		DeregisterView(*iSplashFOView);
		delete iSplashFOView;
	}

	if (iFOView)
	{
		DeregisterView(*iFOView);
		delete iFOView;
	}

#if defined(UIQ) && !defined(MOTOROLA)
	if (iSplashFCView)
	{
		DeregisterView(*iSplashFCView);
		delete iSplashFCView;
	}

	if (iFCView)
	{
		DeregisterView(*iFCView);
		delete iFCView;
	}
#endif

#if defined(SERIES60)
	if (iSettingsView)
	{
		DeregisterView(*iSettingsView);
		delete iSettingsView;
	}

	if (iUserHotkeysView)
	{
		DeregisterView(*iUserHotkeysView);
		delete iUserHotkeysView;
	}

#ifdef PLUGIN_SYSTEM
	if (iCodecSelectionView)
	{
	DeregisterView(*iCodecSelectionView);
	delete iCodecSelectionView;
	}
#endif

#if defined(MULTI_THREAD_PLAYBACK)
	if (iPlaybackOptionsView)
	{
		DeregisterView(*iPlaybackOptionsView);
  		delete iPlaybackOptionsView;
	}
#endif

	if (iAlarmSettingsView)
	{
		DeregisterView(*iAlarmSettingsView);
  		delete iAlarmSettingsView;
	}
#endif // SERIES60

	if(iAppView) RemoveFromStack(iAppView);
	delete iAppView;

#ifdef MONITOR_TELEPHONE_LINE
	delete iActive;
#endif

	delete iOggPlayback;
	iEikonEnv->RootWin().CancelCaptureKey(iCapturedKeyHandle);
	
	delete iSkins;
	delete iOggMsgEnv ;
	delete iSongList;

	iViewHistoryStack.Close();
	iRestoreStack.Close();

	COggLog::Exit();  
}


void COggPlayAppUi::ActivateOggViewL()
{
  TUid viewUid;
  viewUid = iAppView->IsFlipOpen() ? KOggPlayUidFOView : KOggPlayUidFCView;
  ActivateOggViewL(viewUid);
}

void COggPlayAppUi::ActivateOggViewL(const TUid aViewId)
{
	TVwsViewId viewId;
	viewId.iAppUid = KOggPlayUid;
	viewId.iViewUid = aViewId;
	
	ActivateViewL(viewId);
}

void COggPlayAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent)
{
	if (aType == EEventUser+1)
		ActivateOggViewL();
	else 
		CEikAppUi::HandleApplicationSpecificEventL(aType, aEvent);
}

#if !defined(OS70S)
void COggPlayAppUi::NotifyStreamOpen(TInt aErr)
{
	NextStartUpState(aErr);
}
#endif

void COggPlayAppUi::NotifyUpdate()
{
	// Try to resume after sound device was stolen
	if (iTryResume>0 && iOggPlayback->State()==CAbsPlayback::EPaused)
	{
		if (iOggPlayback->State()!=CAbsPlayback::EPaused)
			iTryResume= 0;
		else
		{
			iTryResume--;
			if (iTryResume==0 && iOggPlayback->State()==CAbsPlayback::EPaused) HandleCommandL(EOggPauseResume);
		}
	}
}

void COggPlayAppUi::NotifyPlayInterrupted()
{
	HandleCommandL(EOggPauseResume);
	iTryResume= 2;
}

void COggPlayAppUi::NotifyPlayComplete()
{
	if (iSongList->AnySongPlaying() <0) {
        // Does this really happens?
		iAppView->Update();
		return;
	}
	
    NextSong();
}

#if defined(DELAY_AUDIO_STREAMING_START)
void COggPlayAppUi::NotifyPlayStarted()
{
	// Update the appView and the softkeys
	iAppView->Update();
	UpdateSoftkeys();
}
#endif

void COggPlayAppUi::ResumeUpdates()
{
#if defined(MONITOR_TELEPHONE_LINE)
	if (iActive)
		iActive->IssueRequest();
#endif
}

#if defined(MULTI_THREAD_PLAYBACK)
void COggPlayAppUi::NotifyFatalPlayError()
{
	// Try to exit cleanly
	HandleCommandL(EEikCmdExit);
}
#endif

void
COggPlayAppUi::SetHotKey()
{
	if(iCapturedKeyHandle)
		iEikonEnv->RootWin().CancelCaptureKey(iCapturedKeyHandle);
	iCapturedKeyHandle = 0;
	if(!iHotkey || !keycodes[iHotkey-1].code)
		return;
#if !defined(SERIES60)
	iCapturedKeyHandle = iEikonEnv->RootWin().CaptureKey(keycodes[iHotkey-1].code,
		keycodes[iHotkey-1].mask, keycodes[iHotkey-1].mask, 2);
#else
	iCapturedKeyHandle = iEikonEnv->RootWin().CaptureKey(keycodes[iHotkey-1].code,
		keycodes[iHotkey-1].mask, keycodes[iHotkey-1].mask);
#endif
}

#if defined(SERIES60) || defined(SERIES80) 
void COggPlayAppUi::UpdateSoftkeys(TBool aForce)
#else
void COggPlayAppUi::UpdateSoftkeys(TBool /* aForce */)
#endif
{
#if defined(SERIES60) || defined(SERIES80) 
  // Return if somebody else than main view has taken focus, 
  // except if we override this check.
  // Others must control the CBA themselves
  TVwsViewId viewId;
  GetActiveViewId(viewId);
  if( !aForce && viewId.iViewUid != KOggPlayUidFOView ) 
    return;
  
#ifdef SERIES60
  if(iOggPlayback->State() == CAbsPlayback::EPlaying) {
    COggUserHotkeysS60::SetSoftkeys(ETrue);
  } else {
    COggUserHotkeysS60::SetSoftkeys(EFalse);
  }
#else
  if(iOggPlayback->State() == CAbsPlayback::EPlaying) {
    COggUserHotkeysS80::SetSoftkeys(ETrue);
  } else {
    COggUserHotkeysS80::SetSoftkeys(EFalse);
  }
#endif
  Cba()->DrawNow();
#endif //S60||S80
}


void
COggPlayAppUi::HandleCommandL(int aCommand)
{
  switch (aCommand)
  {
  case EOggAbout:
	{
		COggAboutDialog *d = new(ELeave) COggAboutDialog();
		TBuf<128> buf;
		iEikonEnv->ReadResource(buf, R_OGG_VERSION);
		d->SetVersion(buf);
		d->ExecuteLD(R_DIALOG_ABOUT);
		break;
	}

	case EOggPlay: {
    PlaySelect();
		break;
				   }
		
	case EOggStop: {
    Stop();
		break;
				   }
		
	case EOggPauseResume: {
    PauseResume();
		break;
						  }
		
	case EOggInfo: {
		ShowFileInfo();
		break;
				   }
		
	case EOggShuffle: {     
		SetRandomL(!iSettings.iRandom);
		break;
					  }
		
	case EOggRepeat: {
	    ToggleRepeat();
		break;
					 }
		
	case EOggOptions: {
#if defined(UIQ)
		CHotkeyDialog *hk = new(ELeave) CHotkeyDialog(&iHotkey, &(iSettings.iAlarmActive), &(iSettings.iAlarmTime));
		if (hk->ExecuteLD(R_DIALOG_HOTKEY)==EEikBidOk) {
			SetHotKey();
			iAppView->SetAlarm();
		}
#elif defined(SERIES80)
        CSettingsS80Dialog *hk = new(ELeave) CSettingsS80Dialog(&iSettings);
		hk->ExecuteLD(R_DIALOG_OPTIONS) ;
		UpdateSoftkeys(EFalse);
#elif defined(SERIES60)
        ActivateOggViewL(KOggPlayUidSettingsView);
#endif
		break;
					  }

#ifdef PLUGIN_SYSTEM
    case EOggCodecSelection:
        {
#if defined(SERIES80)
		CCodecsS80Dialog *cd = new(ELeave) CCodecsS80Dialog();
		cd->ExecuteLD(R_DIALOG_CODECS);
#else
         ActivateOggViewL(KOggPlayUidCodecSelectionView);
#endif
		break;
        }
#endif

#if defined(MULTI_THREAD_PLAYBACK)
    case EOggPlaybackOptions:
		ActivateOggViewL(KOggPlayUidPlaybackOptionsView);
		break;
#endif

#if defined(SERIES60)
	case EOggAlarmSettings:
		ActivateOggViewL(KOggPlayUidAlarmSettingsView);
		break;
#endif

	case EOggNextSong: {
		NextSong();
		break;
					   }
		
	case EOggPrevSong: {
		PreviousSong();
		break;
					   }
		
	case EOggViewByTitle:
	case EOggViewByAlbum:
	case EOggViewByArtist:
	case EOggViewByGenre:
	case EOggViewBySubFolder:
	case EOggViewByFileName:
	case EOggViewByPlayList:
        {
			TBuf<16> dummy;
			//iViewBy= aCommand-EOggViewByTitle;
			iAppView->FillView((TViews)(aCommand-EOggViewByTitle), ETop, dummy);
			break;
		}
		
	case EOggViewRebuild: {
		iIsRunningEmbedded = EFalse;

		HandleCommandL(EOggStop);
#ifdef SEARCH_OGGS_FROM_ROOT
        COggFilesSearchDialog *d = new(ELeave) COggFilesSearchDialog(iAppView->iOggFiles);
        if(iSettings.iScanmode==TOggplaySettings::EMmcOgg) {
          iAppView->iOggFiles->SearchSingleDrive(KMmcSearchDir,d,R_DIALOG_FILES_SEARCH,iCoeEnv->FsSession());
        } 
#ifdef SERIES80
		else if(iSettings.iScanmode==TOggplaySettings::ECustomDir) {
          iAppView->iOggFiles->SearchSingleDrive(iSettings.iCustomScanDir,d,R_DIALOG_FILES_SEARCH,iCoeEnv->FsSession());
        } 
#endif
        else {
          iAppView->iOggFiles->SearchAllDrives(d,R_DIALOG_FILES_SEARCH,iCoeEnv->FsSession());

⌨️ 快捷键说明

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