In Windows Phone mango update, we can use videobrush since we cocould 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 mediatimeline in Silverlight for Windows Phone API. how can we repeat m EDIA 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:
PS: I wrote a technical blog in English for the first time. It really hurts D. But to learn e well, it only hurts because I firmly believe that it will not hurt if it hurts!