WP8.1如何取消在C#中的背景音频任务 [英] WP8.1 How to cancel a Background Audio Task in C#

查看:398
本文介绍了WP8.1如何取消在C#中的背景音频任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从应用程序/后台任务在wp8.1取消后台音频任务 - 有没有办法从代码中筹集取消?找不到任何MSDN或其他地方。

I would like to cancel a background audio task from the app/background task in wp8.1 - is there a way to raise cancellation from code? can't find anything on msdn or anywhere else..

背景,为什么我要这么做:
结果在WP8很多用户间没有 ŧ有关的事实,systemmediacontrols活跃一直很逗乐了。同样在wp8.1:微软说,当另一个应用程序要使用背景音乐,或(ii)超时后(我觉得我读它的地方),后台任务应该被取消(I)。因为在我的测试看来,这超时取消从未发生过,我想给用户一个可能性关机孔的应用程序(包括背景音乐)。

Background why i want to do that:
In wp8 a lot of users weren't very amused about the fact that the systemmediacontrols were active all the time. Same in wp8.1: Microsoft says the background task should be cancelled (i) when another app wants to use background audio, or (ii) after timeout (i think i read it somewhere). Since in my tests it seems that this timeout cancellation never happens, i would like to give the user a possibility to shutdown the hole app (incl. background audio).

我将是任何建议感激结果
最佳

I would be grateful for any suggestion.
Best

推荐答案

作为的 BackgroundMediaPlayer 你可以调用的 BackgroundMediaPlayer.Shutdown ,因为它是说在这里MSDN

As for BackgroundMediaPlayer you can call BackgroundMediaPlayer.Shutdown, as it is said here at MSDN:

BackgroundMediaPlayer.Shutdown关闭介质的管道,并从内存中释放MediaPlayer对象。如果您尝试调用shutdown后,再次访问BackgroundMediaPlayer.Current一个参考,你会得到一个错误。关机是为一个应用程序来清理时,它的任务是取消了介质的管道。

BackgroundMediaPlayer.Shutdown closes the media pipeline and release the MediaPlayer object from memory. If you try to access a reference to BackgroundMediaPlayer.Current again after calling Shutdown, you will get an error. Shutdown is meant for an app to clean the media pipeline when its task is cancelled.

所以,要记得拆离前台,后台的所有处理程序沟通和调用的 BackgroundMediaPlayer.Current 的,因为它会再次启动它。

So remember to detach all handlers from Foreground-Background communication and suppress from calling BackgroundMediaPlayer.Current as it will start it again.

这篇关于WP8.1如何取消在C#中的背景音频任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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