WPF媒体元素,https来源失败

时间:2011-05-07 22:26:30

标签: c# wpf media

有没有人见过以下内容?

我在C#WPF项目中使用了MediaElement。我尝试在安全的SharePoint网站(NTLM)上访问视频,我将Source设置为https地址,视频播放失败。

 var u = new Uri(@"https://www......com/WindowsMedia.wmv", UriKind.Absolute);
 mediaElement.Source = u;
 mediaElement.Play();

尝试播放视频时,我得到一个例外:

 Object reference not set to an instance of an object.

我希望有人之前见过这个,并且可以给我一个提示。不幸的是,我无法共享安全的视频位置。

1 个答案:

答案 0 :(得分:0)

我首先要说我对Share Point没有经验但是...... 也许你需要首先在本地下载文件,因为它是通过HTTPS而且MediaElement似乎没有任何验证方法。

所以将文件下载到本地磁盘:

using System;
using System.IO;
using System.Net;

WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("username", "password", "domain");
webClient.DownloadFile("https://servername/path/documentToDownload.txt", "localPathToSaveFile");

然后设置MediaElement.Source =“localPathToSaveFile”