视频在WPF中8到10分钟后自动停止 [英] Video automatically stop after 8 to 10 minutes in WPF
本文介绍了视频在WPF中8到10分钟后自动停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我在wpf中使用Media元素并播放重复行为的视频,但过了一段时间我的视频无法播放请建议我需要什么这样做我的视频永远不会停止或挂起。
我使用的代码如下:
前端:-----
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:-----
<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:-
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;
}
}
推荐答案
这篇关于视频在WPF中8到10分钟后自动停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文