Share via


BackgroundMediaPlayer 类

定义

在后台运行时提供对媒体播放器的访问权限。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

public ref class BackgroundMediaPlayer abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BackgroundMediaPlayer final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Deprecated("Use MediaPlayer instead of BackgroundMediaPlayer.  For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 262144, "Windows.Foundation.UniversalApiContract")]
class BackgroundMediaPlayer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public static class BackgroundMediaPlayer
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Deprecated("Use MediaPlayer instead of BackgroundMediaPlayer.  For more info, see MSDN.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 262144, "Windows.Foundation.UniversalApiContract")]
public static class BackgroundMediaPlayer
Public Class BackgroundMediaPlayer
继承
Object Platform::Object IInspectable BackgroundMediaPlayer
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

注解

从 Windows 10 版本 1607 开始,应用应使用 MediaPlayer 进行媒体播放。 MediaPlayer 对象允许使用单个进程在后台无缝播放媒体。 有关使用 MediaPlayer 的信息,请参阅 使用 MediaPlayer 播放音频和视频。 有关使用 MediaPlayer 在后台播放媒体的信息,请参阅 在后台播放媒体。 有关仍支持向后兼容性的旧式双进程后台播放模型的信息,请参阅 旧版后台媒体播放

属性

Current

获取后台媒体播放器的当前实例。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

方法

IsMediaPlaying()

返回一个布尔值,该值指示设备上当前是否正在播放其他媒体。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

SendMessageToBackground(ValueSet)

向后台媒体播放器发送消息。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

SendMessageToForeground(ValueSet)

向前台任务发送消息。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

Shutdown()

关闭当前后台媒体播放器。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

事件

MessageReceivedFromBackground

从后台任务收到消息时发生。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

MessageReceivedFromForeground

从前台任务收到消息时发生。

注意

从 Windows 版本 1703 开始,BackgroundMediaPlayer 已弃用,并且在 Windows 的未来版本中可能不可用。 请改用 MediaPlayer 类。 有关详细信息,请参阅 在后台播放媒体

适用于

另请参阅