Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I have WPF Project and use media element.
I have Website and I want Stream site video (stream Online) directly on my wpf and media element.
How can I do it?

What I have tried:

I do not know how to do it and When using mediaelement.Source for getting internet address, nothing happened.
Posted
Updated 14-Oct-20 21:17pm

1 solution

Sounds like, you have defined source of video. With it, you can play video:
1. WPF app using MediaElement
HTML
<MediaElement Source="http://yourwebsite/yourvideo.mp4" LoadedBehavior="Manual" Name="mePlayer" />

Refer:Playing video - The complete WPF tutorial[^]

2. HTML5 using video tag
HTML
<video width="320" height="240" controls="">
  <source src="url-to-video.mp4" type="video/mp4"></source>
</video>

try out!
 
Share this answer
 
Comments
link1234 15-Oct-20 4:51am    
Hi I use the link you share. the link in that example work when I use in my program and video run after the load enough buffer data.
But when i use my Own URL or random video link from another site the program show the below error.
"System.NullReferenceException: Object reference not set to an instance of an object"
my video in mp4.
what should I do?
Sandeep Mewara 15-Oct-20 6:48am    
Details about the error you see: NullReferenceException Class (System) | Microsoft Docs[^]
Quote:A NullReferenceException exception is thrown when you try to access a member on a type whose value is null
Possibly because:
1. You've forgotten to instantiate a reference type
2. You've forgotten to dimension an array before initializing it.
3. You get a null return value from a method, and then call a method on the returned type.
4. You're using an expression (for example, you're chaining a list of methods or properties together) to retrieve a value
5. You're enumerating the elements of an array that contains reference types, and your attempt to process one of the elements throws
6. Exception is thrown by a method that is passed null


When you debug, you will be able to get the exact line where the variable is NULL and error is being raised.
link1234 15-Oct-20 8:29am    
my code for this part is:
if (mediaelement.Source != null)
{
mediaelement.Play();
}
the error occur in the mediaelement.play(); line
Sandeep Mewara 15-Oct-20 8:36am    
Sounds like your mediaelement is null. DEBUG please.
link1234 15-Oct-20 9:40am    
I DEBUG my project. when I set the example url in the XAML OR C# Code. the video is running.

mediaelement.Source = new Uri("http://hubblesource.stsci.edu/sources/video/clips/details/images/hst_1.mpg");

But when i use the another video link (for Mp4 type) on both way. the program show the above error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900