简体   繁体   中英

MediaElement windows phone 8

I am trying to play a video in my app. The video and the xaml file are present under the same folder.

My xaml code (which is a user control)

<Grid x:Name="LayoutRoot">        
    <MediaElement x:Name="vid" MediaOpened="MediaElement_MediaOpened" 
                  Source="hey.mp4" AutoPlay="True" />
</Grid>

My xaml.cs file code

public Page1()
{
    InitializeComponent();
}

private void MediaElement_MediaOpened(object sender, RoutedEventArgs e)
{
    vid.Play();
}

The video is not playing. I tried the source to be "/hey.mp4" also, but it didn't play. What is my mistake ?

检查视频的URl并disable locking手机的disable locking功能,您可以这样做,

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM