2011-05-07 113 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」