Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.


From Wiki
Jump to: navigation, search
Article Metadata

需要的签名: Self-Signed
能力: UserEnvironment

关键词: ECam, MCoeForegroundObserver
User:Jiangbaolan 在 02 Apr 2009 创建
最后由 hamishwillee 在 14 Jun 2013 编辑

详细描述 本文章描述了如何保留并释放摄像头资源,当程序激活后(即被带到前台或启动时)或非激活状态(即处于后台或退出)。

为了在获得或失去焦点时正确的处理摄像头资源,程序必须要能响应前台事件。下列代码片段使用MCoeForegroundObserver完成此功能。 该代码可以通过自签名执行。

前提 要执行该代码,程序需要完成对摄像头的使用(如S60 Platform: Camera Example with Autofocus )

MMP文件 需要下列能力和链接库

CAPABILITY UserEnvironment 
LIBRARY ecam.lib


Inherit your class from MCoeForegroundObserver and override the HandleGainingForeground and HandleLosingForeground functions to be able to react to foreground events and handle the camera resource.

#include <ECam.h>           // link against ecam.lib
#include <ccamautofocus.h> // only needed if autofocus extension is meant to be
// used; link against CamAutoFocus.lib
* From MCoeForegroundObserver

virtual void HandleGainingForeground();
virtual void HandleLosingForeground();
CCamera* iCamera;
CCamAutoFocus* iAutoFocus; // optional源文件


iEikonEnv->AddForegroundObserverL( *this );


// Gets called when the application is brought to the foreground
void CYourClass::HandleGainingForeground()
iCamera->Reserve(); // Asynchronous. Calls MCameraObserver::ReserveComplete
// when the request completes.


This page was last modified on 14 June 2013, at 05:00.
54 page views in the last 30 days.