WPF 使用MediaElement,但Source带https会抛出未引用对象实列

原因和解决办法

如果恰好使用了MediaElement,在调用的时候,会出现空异常

var uri = new Uri("https://xxxx.mp4", UriKind.RelativeOrAbsolute);
mediaElement.Source = uri;
mediaElement.Play();//Getting exception here.

因为MediaElement不支持https,所以尽量使用http或者把视频下载下来
参考链接
https://stackoverflow.com/questions/30702505/playing-media-from-https-site-in-media-element-throwing-null-reference-exception?noredirect=1&lq=1#comment49463119_30702505

 

 

posted @ 2022-10-22 11:32  樱花落舞  阅读(143)  评论(0编辑  收藏  举报