积极答复者
MediaElement如何实现在媒体下载完之前边下载边播放,并保存在本地?类似优酷

问题
答案
-
Hi,
MediaElement本身就是支持流媒体播放的,只需要将Source设置为相应的Uri,通过MediaElement.BufferingProgress可以查看到缓存的进度,具体可以参考:
BufferingProgress:
这里有一个例子,写的比较简单你可以看一下:
http://code.msdn.microsoft.com/windowsapps/Windows-8-Video-Player-v2-2122d822
不过这个缓存下来的文件确是不可修改的(即你不能去删除它,这样会出现错误)而且我没有找到这个文件是存在什么地方的。如果你想要自己去实现缓存下来并放到MediaElement中的话,你可能需要StreamSocket来自己实现了。你可以参考这一段代码来实现:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/09ee4142-c607-4914-b50e-a0e54cc69839
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已标记为答案 Aaron XueModerator 2013年1月8日 4:31
全部回复
-
Hi,
MediaElement本身就是支持流媒体播放的,只需要将Source设置为相应的Uri,通过MediaElement.BufferingProgress可以查看到缓存的进度,具体可以参考:
BufferingProgress:
这里有一个例子,写的比较简单你可以看一下:
http://code.msdn.microsoft.com/windowsapps/Windows-8-Video-Player-v2-2122d822
不过这个缓存下来的文件确是不可修改的(即你不能去删除它,这样会出现错误)而且我没有找到这个文件是存在什么地方的。如果你想要自己去实现缓存下来并放到MediaElement中的话,你可能需要StreamSocket来自己实现了。你可以参考这一段代码来实现:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/09ee4142-c607-4914-b50e-a0e54cc69839
Aaron
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已标记为答案 Aaron XueModerator 2013年1月8日 4:31