Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing media from https site in media element throwing null reference exception in wpf

Tags:

c#

wpf

I am trying to Play video from https site into my media element throwing the following exception.

An exception of type 'System.NullReferenceException' occurred in PresentationCore.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.

This is my code in xmal

 <MediaElement x:Name="mediaElement" LoadedBehavior="Manual"  Stretch="Fill" Loaded="OnMediaElementLoaded" MediaOpened="MediaElement_OnMediaOpened" />

var uri = new Uri("https://f60b7719060a37f20253-4343910d3bf76239b8a83e4f56d17dc5.ssl.cf2.rackcdn.com/mov-2015-06-07-22-08-09-391574e61009867cfcb1a1641639b39e55c8a34c.mp4", UriKind.RelativeOrAbsolute);
mediaElement.Source = uri;
mediaElement.Play();//Getting exception here.

Any help please? I also tried the same using the some other http.

like image 891
user1845163 Avatar asked Jun 08 '15 06:06

user1845163


1 Answers

Commentators are trying to look smart by giving completely irrelevant information, but the MediaElement, in fact, can't play from HTTPS sources, a bug that has been acknowledged and not prioritized enough to get fixed.

You will either have to supply a non-HTTPS source url or save the content to file first and then load it (can be accomplished with a virtualized file system).

like image 71
Tyrrrz Avatar answered Oct 15 '22 01:10

Tyrrrz