MediaElement 网络视频不会停止缓冲 [英] MediaElement web Video doesn't stop buffering

查看:19
本文介绍了MediaElement 网络视频不会停止缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MediaElement 播放网络视频.当我离开页面时,我在任务管理器中注意到我的应用程序仍在使用 10% 的网络,并且直到它完成下载视频才停止.

I m using MediaElement to play a web video. When I left the page I noticed in the Task Manager that my app was still using 10% of network and didn't drop till it finished downloading video.

我尝试执行以下操作,但没有成功.

I tried doing the following but no luck.

    //open link;
    mediaElement.Source = welcomeVideoURL;

    //when I leave the page OnNavigatedFrom()
    mediaElement.Stop();
    mediaElement.ClearValue(MediaElement.SourceProperty);
    mediaElement.Source = null;

还尝试将源设置为虚拟链接,但仍然没有运气.

Also tried to set the source to a dummy link but still no luck.

我认为将链接作为流打开并使用 mediaElement.SetSource() 可以工作,但我没有找到任何关于它的东西......也许我没有正确搜索.

I thought that opening the Link as a Stream and use mediaElement.SetSource() could work but I haven't found anything on that...maybe I m not searching correct.

谢谢.

推荐答案

在某些地方发现了这个 MediaElementWithHttpClient评论中的其他问题来自@kiewic.我可以管理流和下载过程并轻松处理它.

Found this MediaElementWithHttpClient in some other question in a comment made by @kiewic. I can manage the stream and download process and easily dispose it.

 HttpRandomAccessStream videoStream = await HttpRandomAccessStream.CreateAsync(new Windows.Web.Http.HttpClient(), videoUrl);
 mediaElement.SetSource(videoStream, videoStream.ContentType);

这篇关于MediaElement 网络视频不会停止缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆