Search code examples
windows-phone-7videowindows-phone-7.1mediaelement

Why does MediaElement show nothing?


I tried different ways, but whatever I set to Source of MediaElement it shows nothing.

I try this way:

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,0,0,0" Background="White">
        <MediaElement x:Name="VideoMediElement" Source="{Binding VideoUrl, Mode=TwoWay}" Width="350" Height="340" Margin="55,33,75,225"></MediaElement>
    </Grid>

I try this:

VideoMediElement.Source = new Uri(VideoUrl);
VideoMediElement.Play();

where VideoUrl is:

 private string videoUrl;
    public string VideoUrl
    {
        get { return videoUrl; }
        set
        {
            if (videoUrl != value)
            {
                videoUrl = value;
                OnPropertyChanged("VideoUrl");
            }
        }
    }

I even try this:

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,0,0,0" Background="White">
        <MediaElement x:Name="VideoMediElement" Source="http://www.youtube.com/v/zsGczPb-4fg?f=videos" Width="350" Height="340" Margin="55,33,75,225"></MediaElement>

But anywhere I see only white background. Why? I use emulator version 7.1 .


Solution

  • Well did you tried subscribing to event MediaFailed? Maybe something is going wrong with your video and this event may help you find out what.

    Also try your application on device. However you cannot play media when you are connected to device via Zune. You have to use WPConnect. It will allow you to connect to phone without Zune and play media in application.