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

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:-----
C#
<mediaelement name="myMediaElement" ismuted="True" stretch="Fill" width="768" height="500" unloadedbehavior="Stop" loadedbehavior="Manual">
                   <mediaelement.triggers>
                       <eventtrigger routedevent="MediaElement.Loaded">
                           <eventtrigger.actions>
                               <beginstoryboard>
                                   <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" />

                                   </mediatimeline></storyboard>
                               </beginstoryboard>
                           </eventtrigger.actions>
                       </eventtrigger>
                   </mediaelement.triggers>
               </mediaelement>


Code Behind:-

C#
public MainGameWindow()
        {
            
                InitializeComponent();             
                myMediaElement.Loaded += new RoutedEventHandler(myMediaElement_Loaded);
              
                   }




      private void playVideoWithRepet()
        {
            try
            {
                string filePath = string.Empty;
                string _pathVedioRotater = _dynamicFilePath + "TopVideoRotate.xml";
                var doc = new XmlDocument();
                doc.Load(_pathVedioRotater);
                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;
            }

        }
Posted
Updated 15-Apr-14 9:00am
v2
Comments
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 ?
thanks

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