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.
PS:第一次用英文寫技術部落格,真D疼,奈何為了學好E文,隻好疼下去了,因為我堅信:疼着疼着就不疼了!
本文轉自xshf12345 51CTO部落格,原文連結:http://blog.51cto.com/alexis/672031,如需轉載請自行聯系原作者