locked
Media problem when doing the "September 2005 hands on lab 08 with the December 2005 CTP" RRS feed

  • Question

  • Hello!

    I'm trying to do the first media stuff in the September 2005 hands on lab 08 with the December 2005 CTP. On page 18 of the hands on lab 08 MS Word document it reads that I must enter this:

    <TextBlock.Background>
     <VisualBrush>
      <VisualBrush.Visual>
       <MediaElement>
        <MediaElement.Source>
         <MediaTimeline Source="C:\Documents and Settings\Henrik Dahl\Dokumenter\MSDN\WPF Hands-On-Lab September 05 CTP\PRSHOL08\HOL-PRSHOL08\Source\apollo11_launchclip04.mpg" RepeatBehaviour="Forever" />
        </MediaElement.Source>
       </MediaElement>
      </VisualBrush.Visual>
     </VisualBrush>
    </TextBlock.Background>

    The problem just is that it's claimed the <MediaElement.Source> element is not a valid child of <MediaElement>, so now I do not know how to play the video.

    Do some of you know if something has changed since the September 2005 CTP or how to continue?

     

    Best regards,

    Henrik Dahl

     

    Monday, December 26, 2005 5:26 PM

Answers

  • In order to use a MediaTimeline, you need to have it inside of a trigger, such as an EventTrigger.  Try the following code inside of your TextBlock:

    <TextBlock>
    <TextBlock.Triggers>
      <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <EventTrigger.Actions>
          <BeginStoryboard>
            <Storyboard>
              <MediaTimeline Storyboard.TargetName="myME" Source="db.wmv" RepeatBehavior="Forever"/>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger.Actions>
      </EventTrigger>
    </TextBlock.Triggers>
    <TextBlock.Background>
     <VisualBrush>
      <VisualBrush.Visual>
       <MediaElement Name="myME">
       </MediaElement>
      </VisualBrush.Visual>
     </VisualBrush>
    </TextBlock.Background>
    </TextBlock>

    Another thing you need to do here is to listen to the TextBlock's Loaded event.  You could listen to other events, but the MediaElement will not receive Loaded since it is inside of a VisualBrush.

     

    Wednesday, January 18, 2006 5:46 PM