暂停相机时,用户从应用程序切换离开,而当用户切换回应用程序恢复摄像头 [英] Suspend camera when user switches away from app, and resume camera when user switches back to app

查看:212
本文介绍了暂停相机时,用户从应用程序切换离开,而当用户切换回应用程序恢复摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我想,当用户从我的应用程序切换离开暂停我的相机,并恢复相机时,用户切换回应用程序

Currently, I would like to suspend my camera when user switches away from my app, and resume camera when user switches back to app

我指的<一个HREF =http://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx#app_suspend相对=nofollow>应用程序生命周期(Windows应用商店的应用程序)(Windows)中

然而,暂停|暂停事件没有被立即一旦用户切换,从我的应用程序走触发。你需要等待几秒钟(或不会触发在所有如果OS决定不这样做)。

However, Suspending | suspending event isn't being triggered immediately once the user switches away from my app. You need to wait for few seconds (Or it will not trigger at all if OS decides not to do so).

所以,我怎么能知道,当我应该运行当用户切换从我的应用程序了我的相机悬挂的代码。

So, how I can know, when I should run my camera suspension code when user switches away from my app.

如果我指的使用捕捉设备样品媒体捕获,他们使用的是

If I referring to Media capture using capture device sample, they are using

视窗.Media.MediaControl.SoundLevelChanged + = m_soundLevelHandler;

他们跑得相机悬挂的代码时,有一个声音电平的变化?但是,这也不是我想要的。由于检测 SoundLevelChanged 事件,是不是能够让我知道,用户是否从我的应用程序切换离开切换回我的应用 SoundLevelChanged 活动将在两种情况下被触发。

They run camera suspension code when there is a sound level changes? But this is also not what I want. As detecting SoundLevelChanged event, is not able to let me know, whether user is switching away from my app, or switching back to my app. SoundLevelChanged event will be triggered in both scenarios.

推荐答案

在< A HREF =http://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx#app_visibility相对=nofollow> MSDN文章你提到。

应用可视性
当从您的应用程序的用户切换到另一个应用程序,
你的应用程序不再可见,但仍处于运行状态,直到
Windows可以将其挂起(约10秒)。如果用户从您的应用程序切换
遥远,但启动或切换回之前的Windows
可以暂停它,应用程序保持在运行状态。您的应用程序并不
收到激活事件时,应用可见性的变化,因为
的应用程序仍在运行。窗户简单切换,并从应用程序在必要时
。如果您的应用需要做一些事情,当用户切换
走和背部,它可以处理 VisibilityChanged |
msvisibilitychange 事件。能见度事件与
简历或激活事件序列化。不要以为这些事件都在一个特定的顺序

App visibility When the user switches from your app to another app, your app is no longer visible but remains in the running state until Windows can suspend it (for about 10 seconds). If the user switches away from your app but activates or switches back to it before Windows can suspend it, the app remains in the running state. Your app doesn't receive an activation event when app visibility changes, because the app is still running. Windows simply switches to and from the app as necessary. If your app needs to do something when the user switches away and back, it can handle the VisibilityChanged | msvisibilitychange event. The visibility event is not serialized with the resume or activation events. Don't assume that these events come in a particular order.

签出的 VisibilityChangedEvent

这篇关于暂停相机时,用户从应用程序切换离开,而当用户切换回应用程序恢复摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆