简体   繁体   English

MediaElement Windows Phone 8

[英]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. 视频和xaml文件位于同一文件夹下。

My xaml code (which is a user control) 我的xaml代码(是一个用户控件)

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

My xaml.cs file code 我的xaml.cs文件代码

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. 我也尝试将源代码设为“ /hey.mp4”,但没有播放。 What is my mistake ? 我的错是什么?

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

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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