视频在WPF中8到10分钟后自动停止

时间:2014-04-15 18:57:41

标签: wpf wpftoolkit wpf-4.0

我在wpf中使用Media元素并以重复行为播放视频,但过了一段时间我的视频无法播放请建议我需要做什么,以便我的视频永不停止或挂起。 我使用的代码如下所示

前端: -

  <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" />

                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </MediaElement.Triggers>
                </MediaElement>

代码背后: -

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

            }
            catch (Exception ex)
            {

            }
        }

private void playVideoWithRepet()         {             尝试             {                 string filePath = string.Empty;                 string _pathVedioRotater = _dynamicFilePath +&#34; TopVideoRotate.xml&#34 ;;                 var doc = new XmlDocument();                 doc.Load(_pathVedioRotater);                 XmlNodeList setting = doc.GetElementsByTagName(&#34; Video&#34;);                 foreach(设置中的XmlNode项)                 {                     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;
        }

    }

0 个答案:

没有答案