在Windows Phone 8中播放视频的代码

本文关键字:视频 代码 播放 Windows Phone | 更新日期: 2023-09-27 18:08:42

谁能告诉我怎么在windows phone上播放视频?

我已经在列表框中显示了我所有的视频。当我点击一个特定的视频立即它应该导航到其他页面和播放。当我点击一个特定的视频,它是导航到其他页面,但不播放。我没有得到错误,甚至警告。

导航页中的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 phone应用程序的初学者。

请谁来帮帮我。

许多谢谢。

在Windows Phone 8中播放视频的代码

Try This

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

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

希望能有所帮助