try
{
AdaptiveMediaSourceCreationResult result = await AdaptiveMediaSource.CreateFromUriAsync(uri);
AdaptiveMediaSource ams = result.MediaSource;
if (result.Status == AdaptiveMediaSourceCreationStatus.Success)
{
ams = result.MediaSource;
mediaElement.SetMediaStreamSource(ams);
}
else
{
await new MessageDialog("无法播放").ShowAsync();
}
}
catch (Exception ex)
{
await new MessageDialog(ex.ToString()).ShowAsync();
}
您好!看到uwp的MediaElement支持播放Hls实时视频了,我就用这种方法试了试,发现有时候Hls可以播放,有时候又总是报异常,异常如下:
System.Runtime.InteropServices.COMException (0xC00D36B2): 当前状态的请求无效。
当前状态的请求无效。
at Windows.Media.Streaming.Adaptive.AdaptiveMediaSourceCreationResult.get_MediaSource()
at MyApp.CurrentLiveView.<InitializeAdaptiveMediaSource>d__8.MoveNext()
调试发现 在 第一步 result那里,报异常的时候值总是为null,但是上一步的URL的确是存在的。这个问题困扰我好久了,希望能得到帮助!