HOW TO:重複播放媒體How to: Repeat Media Playback

此範例顯示如何無限期地撥放,亦即,將媒體設定為不斷地重播。This example shows how to playback media indefinitely, that is, to set media so that it plays in an infinite loop.


下列範例會使用MediaElementMediaTimelineStoryboard播放媒體短片,無限迴圈。The following example uses MediaElement and MediaTimeline in a Storyboard to play a media clip in an infinite loop.

<Page xmlns=""
  xmlns:x="" >

    <!-- The MediaElement control plays the sound. -->
    <MediaElement Name="myMediaElement" >
        <EventTrigger RoutedEvent="MediaElement.Loaded">

                <!-- 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" />



另請參閱See also