当前位置: 移动技术网 > IT编程>移动开发>WP > Windows Phone 实用开发技巧(21):自动循环播放视频

Windows Phone 实用开发技巧(21):自动循环播放视频

2018年10月09日  | 移动技术网IT编程  | 我要评论

红色家具,邓晓逍,随心呼

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 :

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网