Click here to Skip to main content
15,919,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am using Media element in wpf and playing a video in repeat behaviour but after some time my video doesn't play please suggest what i need to do so that my video never stop or hangs.
Code which i use is given below

Front end:-----
<mediaelement name="myMediaElement" ismuted="True" stretch="Fill" width="768" height="500" unloadedbehavior="Stop" loadedbehavior="Manual">
                       <eventtrigger routedevent="MediaElement.Loaded">
                                   <storyboard slipbehavior="Slip">

                                       <!-- The MediaTimeline has a RepeatBehavior="Forever" which makes the media play
                over and over indefinitely.-->
                                       <mediatimeline name="videomediaTimeline" storyboard.targetname="myMediaElement">
                                               RepeatBehavior="Forever" />


Code Behind:-

public MainGameWindow()
                myMediaElement.Loaded += new RoutedEventHandler(myMediaElement_Loaded);

      private void playVideoWithRepet()
                string filePath = string.Empty;
                string _pathVedioRotater = _dynamicFilePath + "TopVideoRotate.xml";
                var doc = new XmlDocument();
                XmlNodeList setting = doc.GetElementsByTagName("Video");
                foreach (XmlNode item in setting)
                    filePath = item.ChildNodes[2].InnerText.ToString();

                string videopath = _dynamicFilePath + "TopContanerVideo/" + filePath;

                videomediaTimeline.Source = new Uri(videopath, UriKind.RelativeOrAbsolute);
                doc = null;
                _pathVedioRotater = null;
                filePath = string.Empty;
                videopath = null;
                setting = null;

            catch (Exception ex)

                throw ex;

Updated 15-Apr-14 9:00am
User-8621695 12-Dec-14 7:37am    
I resolve this issue by myself.
fungerbang 3-Feb-15 19:04pm    
Hi, i have same problem

How did you fix it ?

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900