WPF Video loop from point a to b -
is there way loop video in wpf point b? & b indicates time. example want loop video & loop starts 1 minute of video , ends @ 2 minute of video.
xaml
<mediaelement x:name="myvideo" loaded="myvideo_loaded" loadedbehavior="manual" source="c:\somefolder\somevideo.mp4" />
codebehind
public partial class mainwindow : window { private dispatchertimer dispatchertimer; /// <summary> /// initializes new instance of mainwindow class. /// </summary> public mainwindow() { initializecomponent(); //set dispatchertimer tick interval of 1 minute dispatchertimer = new dispatchertimer(); dispatchertimer.tick += new eventhandler(dispatchertimer_tick); dispatchertimer.interval = new timespan(0, 1, 0); } //occurs when mediaelement loaded private void myvideo_loaded(object sender, routedeventargs e) { //set mediaelement position 1 minute , play myvideo.position = timespan.fromminutes(1); myvideo.play(); //start timer dispatchertimer.start(); } //occurs every tick private void dispatchertimer_tick(object sender, eventargs e) { //at end of tick period, reset mediaelement position , play again myvideo.position = timespan.fromminutes(1); myvideo.play(); //disable/reset timer dispatchertimer.isenabled = false; //restart timer dispatchertimer.start(); } }
Comments
Post a Comment