[UWP]停止背景音频 [英] [UWP]Stop background audio

查看:68
本文介绍了[UWP]停止背景音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过MediaPlayerElement和MediaPlayer创建一个简单的媒体播放器。

I'm creating a simple media player via MediaPlayerElement and MediaPlayer.

我知道如何实现后台播放通过这些控件。

I know how to implement background playback via these controls.

我的问题是如何停止在后台播放并且只在前台播放?并在此之间切换?。

My question is how to stop playing in the background and only play in foreground? and switch between this?.

bool backgroundPlayback = true;

if(backgroundPlayback)

{

// play even in background

}

else

{

// play only in foreground, no more background playback.

}

谢谢。

推荐答案

我不得不说目前没有这种方式来显示背景媒体在清单中启用功能时,代码中的播放功能。 

I have to say currently there is no such way to display background media playback capability in code when the capability is enabled in manifest. 

可能的方法是,当应用程序进入后台时,您可以手动停止媒体播放。如果要停用播放后台媒体,请处理​​ CoreApplication.EnteredBackground
活动
。然后停止媒体播放。 

A possible way is that you could manually stop the media playback when the app is entering background. When you want to disable background media playback, handle the CoreApplication.EnteredBackground Event. Then stop the media playback. 

有关应用生命周期的更多信息,请参阅以下链接: Windows 10通用Windows平台(UWP)应用程序生命周期

For more information about app lifecycle, please refer this link:Windows 10 universal Windows platform (UWP) app lifecycle.

祝你好运,

Roy


这篇关于[UWP]停止背景音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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