Here's how the WebClient headers-property looks like:
Code:
client = new CookieWebClient();
string username = "username";
string password = "password";
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)));
var authHeader = string.Format("Basic {0}", token);
client.Headers["Authorization"] = authHeader;
Oh, and I should explain: I'm using an extended version of the WebClient class because the connection didn't otherwise work. The extended class basically handles cookies better, and it's made following this post: http://firebelly.net/post/3341374382...client-for-wp7
And yes, I just tried the UriBuilder but the MediaElement page is blank so I guess the video couldn't be accessed.
I'm not 100% sure I used the UriBuilder correctly though. Heres my code:
Code:
Uri site = new Uri("https://server.somesite.com/ba/php/download.php?url=" + videoFileID);
UriBuilder stream = new UriBuilder(site);
stream.UserName = "username";
stream.Password = "password";
MediaElement videoPlayer = new MediaElement();
videoPlayer.Source = stream.Uri;
videoPlayer.AutoPlay = true;
LayoutRoot.Children.Add(videoPlayer);
videoPlayer.Play();
Is it known that you can access Basic Authentication server files with UriBuilder?
A colleague is doing a same kind of application for this service on Android and he told me he had to do some kind of double buffering by downloading the video to phone memory and streaming it from there. I'm not completely sure what this means but maybe it can help with this matter. And if I did download the video to the phone storage I would also have to figure out a way to delete it after the user no longer plays the file.