gpt4 book ai didi

audio - MediaPlayerElement vs MediaElement 选哪个?

转载 作者:行者123 更新时间:2023-12-03 00:26:23 24 4
gpt4 key购买 nike

我已经通过answer此处提供差异。但我只需要播放 2 秒钟的通知声音作为警报。没有视频或任何其他繁重的负载。
这是我要播放的通知声音。

ms-winsoundevent:Notification.SMS
以下是 MediaPlayerElement:
MediaPlayerElement mediaPlayerElement = new MediaPlayerElement();
mediaPlayerElement.SetMediaPlayer(new Windows.Media.Playback.MediaPlayer { AudioCategory = Windows.Media.Playback.MediaPlayerAudioCategory.Alerts});
mediaPlayerElement.MediaPlayer.AudioCategory = Windows.Media.Playback.MediaPlayerAudioCategory.Alerts;
mediaPlayerElement.Source = Windows.Media.Core.MediaSource.CreateFromUri(new Uri("ms-winsoundevent:Notification.Default"));
mediaPlayerElement.AutoPlay = false;
mediaPlayerElement.MediaPlayer.Play();
以下是针对 MediaElement 的:
MediaElement mediaElement = new MediaElement();
mediaElement.AudioCategory = AudioCategory.Alerts;
mediaElement.Source = new Uri("ms-winsoundevent:Notification.Default");
mediaElement.AutoPlay = false;
mediaElement.Play();
我可以使用 MediaElement,因为它是一个小音频,还是应该只使用 Microsoft 规定的 MediaPlayerElement?在这种情况下哪个更好用?
P.S.:我需要将音频类别设置为警报以使任何背景音乐变暗。

最佳答案

Can I use MediaElement since its a small audio or should I only use MediaPlayerElement as it is the one prescribed by Microsoft? which one is better to use in this case?



来源于官方 document ,

In Windows 10, build 1607 and on we recommend that you use MediaPlayerElement in place of MediaElement. MediaPlayerElement has the same functionality as MediaElement, while also enabling more advanced media playback scenarios. Additionally, all future improvements in media playback will happen in MediaPlayerElement.



这意味着新功能将在 MediaPlayerElement 的基础上开发。 , 我们推荐使用 MediaPlayerElement这可以使您的应用程序具有更长的生命周期。

关于audio - MediaPlayerElement vs MediaElement 选哪个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58609535/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com