2014-06-16 48 views
0

任何人都可以帮助我如何在Windows Phone中播放视频。在Windows Phone 8中播放视频的代码

我已将所有视频显示在列表框中。当我点击某个特定视频时,应立即导航到其他页面并播放。当我点击某个特定视频时,它正在导航到其他页面但未播放。我没有得到任何错误,甚至警告。

XAML代码在导航页面:在导航页

<MediaElement x:Name="player" AutoPlay="True"/> 

Xaml.cs代码:

protected async override void OnNavigatedTo(NavigationEventArgs e) 
     { 
      if (!NetworkInterface.GetIsNetworkAvailable()) 
      { 
       MessageBox.Show("An error has occurred! Please verify your internet connection."); 
       NavigationService.GoBack(); 
      } 
      else 
      { 

      string songcode = ""; 
      if (NavigationContext.QueryString.TryGetValue("songcode", out songcode)) 
      { 
       var url = await YouTube.GetVideoUriAsync(songcode, YouTubeQuality.Quality480P); 
       player.Source = url.Uri; 
      } 

我是在Windows手机应用程序初学者。

请有人帮我这个。

非常感谢。

回答

0

尝试这个

<MediaElement x:Name="player" AutoPlay="True" MediaOpened="player_MediaOpened"/> 


private void player_MediaOpened(object sender, RoutedEventArgs e) 
    { 
     player.Play(); 

    } 

希望这有助于

+0

我已经尝试过了,即使只有黑屏是displayed.Video是不是在玩。 – deepu

+0

@deepu是你在模拟器上做的吗?可能只与设备一起工作,我想是的。请确保您的视频格式正确[格式支持](http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff462087(v = vs.105).aspx#BKMK_VideoSupport) – Eldho

+0

Yes i是在模拟器上做的。 – deepu