c# - WPF: How to play video (mp4 format) from servrer in MediaElement? -
i want play video directly server in mediaelement. (the source server) have url of server: http://videotherapy.co/dev/vt/api/dispatcher.php
and post following json:
{"videoid":"22-1","api":"get-training-video"} (where 22-1 videoid)
xaml code:
<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(); } } }
how this? help.
the mediaelement
accepts uri source
. this, can stream video web client application.
if somehow not possible in case. you'll have download video file
. pass location of file source
property of mediaelement
Comments
Post a Comment