Click here to Skip to main content
14,305,268 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,

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.LoadedBehavior=MediaState.Manual;		    
			    m1 .Height =65;
			    m1 .Width =65;					
		            m1 .Source =obj1;  
                            media1 .Source =obj1; // media element source.	                   
uniformgrid1 .Children .Add (m1);
Posted
Updated 10-Jul-11 21:48pm
v3

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100