Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i want to play the video clip.By clicking on video clip the particular video clip should play in a media element.

I have multiple video clips on a grid in WPF form(these videos are selected from open file dialog box).on the same window i have a media element, now i want to play any video by clicking on it, the video should play in a Mediaplayer.The problem is it is playing only the last video loaded from Openfile dialogbox. How to get the uri of a particular video when i click on the video.

Please some one explain the correct way to do this.

Code is like this:
// when i click on a button
OpenFileDialog fd1=new OpenFileDialog ();
	Nullable<bool> result = fd1.ShowDialog();             
               if (result == true) 
                 media1 .Stop();
              Uri obj1=new Uri (fd1 .FileName );            
                MediaElement m1=new MediaElement ();
			    m1 .Height =65;
			    m1 .Width =65;					
		            m1 .Source =obj1;  
                            media1 .Source =obj1; // media element source.	                   
uniformgrid1 .Children .Add (m1);
Updated 10-Jul-11 22:48pm

1 solution

Iam not sure but i think there is no click event for mediaelement in wpf.
U have to take button, under button click event play the mediaelement.
Share this answer

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