Windows Phone 实用开发技巧(21):自动循环播放视频
in windows phone mango update, we can use videobrush since we could not do that in windows phone 7 . so there is something interesting to do. we can develop more fantasitic apps. for example, we can play a video as background in our application. we want to play video in a loop also. but here comes the problem. since there is no x" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(255, 102, 0); text-decoration: none; ">mediatimeline in silverlight for windows phone api. how can we repeat media playback ?
in wpf or silverlight, we can use following code to repeat media playback.
<page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<stackpanel>
<!-- the mediaelement control plays the sound. -->
<mediaelement name="mymediaelement" >
<mediaelement.triggers>
<eventtrigger routedevent="mediaelement.loaded">
<eventtrigger.actions>
<beginstoryboard>
<storyboard>
<!-- the mediatimeline has a repeatbehavior="forever" which makes the media play
over and over indefinitely.-->
<mediatimeline source="media\tada.wav" storyboard.targetname="mymediaelement"
repeatbehavior="forever" />
</storyboard>
</beginstoryboard>
</eventtrigger.actions>
</eventtrigger>
</mediaelement.triggers>
</mediaelement>
</stackpanel></page>
in windows phone , i find simple solution to play video in a loop. since we can catch media_end event, we can play again in ended event.
another suggestion : do not play large video in your windows phone app since it will cause a little bit performance damage.
source code can be found here :
上一篇: 经典笑语走向了人生巅峰
推荐阅读
-
Windows Phone 实用开发技巧(3):输入框自动聚焦并打开SIP
-
Windows Phone 实用开发技巧(26):对DataTemplate中的元素播放动画
-
Windows Phone 实用开发技巧(21):自动循环播放视频
-
Windows Phone 实用开发技巧(5):让你的手机在运行应用程序运行时不自动锁屏
-
Windows Phone 实用开发技巧(21):自动循环播放视频
-
Windows Phone 实用开发技巧(26):对DataTemplate中的元素播放动画
-
Windows Phone 实用开发技巧(3):输入框自动聚焦并打开SIP
-
Windows Phone 实用开发技巧(5):让你的手机在运行应用程序运行时不自动锁屏