通过在WPF中单击在媒体播放器中播放视频 [英] Playing a video in media player by clicking on it in WPF

查看:66
本文介绍了通过在WPF中单击在媒体播放器中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想播放视频剪辑.通过单击视频剪辑,特定的视频剪辑应在媒体元素中播放.

我在WPF格式的网格上有多个视频剪辑(这些视频是从打开文件对话框中选择的).在同一窗口上,我有一个媒体元素,现在我想通过单击播放任何视频,该视频应以一个Mediaplayer.问题是它只播放从Openfile对话框加载的最后一个视频.当我单击视频时,如何获取特定视频的uri.

请有人解释正确的方法.

代码是这样的:

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);

推荐答案

我不确定,但我认为wpf中没有用于中介的点击事件.
您必须按下按钮,在按钮单击事件下播放中介元素.
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.


这篇关于通过在WPF中单击在媒体播放器中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆