locked
Xaml MediaElement RRS feed

  • Question

  • I'm developing a metro style app that includes a MediaElement, here's my code:

    xaml Code:

    <MediaElementx:Name="media"Width="300"Height="300" Source="test.wma"/>

    C# Code:

    private voidPlay_Click(objectsender, RoutedEventArgse)

    {

     media.Play();

    }

    The problem is that nothing happens when Play button is clicked.

    Wednesday, August 8, 2012 1:25 PM

All replies

  • To diagnose, try attaching event handlers like this..

        <MediaElement x:Name="media"
                    Width="300"
                    Height="300"
                    Source="test.wma"
                    MediaFailed="media_MediaFailed_1"
                    MediaOpened="media_MediaOpened_1"/>
    
    put breakpoints in the handlers and see which gets called - if failed, then inspect the exception.

    http://babaandthepigman.spaces.live.com/blog/

    Wednesday, August 8, 2012 2:36 PM
  • If test.wma is embedded in your project, make sure the Build Action property for the file is set to "Content".

    Thursday, October 11, 2012 12:21 AM