问题描述
使用以下代码(Xbox自托管的html / js应用)时,我可以获得播放的声音,可以看不到视频。有什么我想念的吗?我需要使用& AdaptiveMediaSource api,因为使用< video />元素似乎泄漏内存
具有高比特率HLS,而MediaPlayer提供了一种限制最大比特率的方法。
When using the following code (Xbox self hosted html/js app), I can get the sound to play, can can not see the video. Is there something I am missing? I need to use the AdaptiveMediaSource api since using a <video /> element seems to leak memory with high bitrate HLS, and MediaPlayer provides a way to cap the max bitrate.
感谢您的支持帮助!
const encoding = 'http://content.uplynk.com/52ab86c3f6c74d6abf7f162204d51609.m3u8'
&NBSP; const encodingUri = new window.Windows.Foundation.Uri(encoding);
&NBSP; Windows.Media.Streaming.Adaptive.AdaptiveMediaSource
&NBSP; &NBSP; &NBSP; .createFromUriAsync(encodingUri)
&NBSP; &NBSP; &NBSP; .then(result => {
let player = new Windows.Media.Playback.MediaPlayer(this.player);
player .autoPlay = true;
const source = Windows.Media.Core.MediaSource.createFromAdaptiveMediaSource(
result.mediaSource
); player.source = source;
player.play();
});
const encodingUri = new window.Windows.Foundation.Uri(encoding);
Windows.Media.Streaming.Adaptive.AdaptiveMediaSource
.createFromUriAsync(encodingUri)
.then(result => {
let player = new Windows.Media.Playback.MediaPlayer(this.player);
player.autoPlay = true;
const source = Windows.Media.Core.MediaSource.createFromAdaptiveMediaSource(
result.mediaSource
);
player.source = source;
player.play();
});
推荐答案
这是一个类似的主题 [UWP] [HTML]使用Windows.Media.Playback.MediaPlayer ,你可以找到
来自@Elvis Xia的答案:
Here is a similar thread [UWP][HTML]Using Windows.Media.Playback.MediaPlayer, you can find the answer from the @Elvis Xia:
据我所知,Windows.Media.Playback.MediaPlayer目前依赖的是XAML或Composition API,它们在html中不可用。
因此,无法在UWP(JS)中使用Windows.Media.Playback.MediaPlayer和视频元素。
如果您对此功能仍有要求,可以尝试将您的想法提交到用户语音网站: https://wpdev.uservoice.com/ 。
您还可以在Windows 10反馈应用中提交此功能请求/反馈。
祝你好运,
Breeze
这篇关于[XBOX] [UWP] [JS] [HTML] AdaptiveMediaSource MediaPlayer可以听到声音,但看不到播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!