c# - WPF: Why MediaElement does not play? -
i want display video. want video play click on button. video not play. put video project.
i want video source youtube.
my xaml code is:
<window x:class="mediaelementapp.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="467.91" width="1300"> <grid> <mediaelement x:name="mediaelement" horizontalalignment="left" height="418" margin="246,10,0,0" verticalalignment="top" width="1036" loadedbehavior="manual" unloadedbehavior="stop" source="images\wildlife.wmv" /> <button x:name="play" horizontalalignment="left" margin="538,161,0,0" verticalalignment="top" width="100" height="84" click="play_click" > <button.background> <imagebrush imagesource="images/smiley.jpg"/> </button.background> </button> </grid> c# code:
using system; using system.collections.generic; using system.linq; using system.text; using system.windows; using system.windows.controls; using system.windows.data; using system.windows.documents; using system.windows.input; using system.windows.media; using system.windows.media.imaging; using system.windows.navigation; using system.windows.shapes; namespace mediaelementapp { /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { public mainwindow() { initializecomponent(); } private void play_click(object sender, routedeventargs e) { mediaelement.play(); } } } i help.
the media source should file system example
mediaelement.source = new uri(@"c:\user\admin\images\wildlife.wmv")
Comments
Post a Comment