2011-05-07 111 views
5

有没有人看到以下内容?WPF媒体元素,https来源失败

我在C#WPF项目中使用了MediaElement。我试图访问安全SharePoint站点(NTLM)上的视频,我将源设置为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. 

我希望以前有人已经看到了这一点,可以给我一个提示。不幸的是,我无法分享安全的视频位置。

+0

什么是调用堆栈,当异常被抛出? – Jon 2011-05-07 22:48:16

回答

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”