【问题标题】:PLaying Default Video in Windows Phone 8在 Windows Phone 8 中播放默认视频
【发布时间】:2014-09-10 21:49:27
【问题描述】:

我已经解析了 RSS 提要 http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6。 并在水平列表视图中显示歌曲。如下所示

当我单击上面空间中正在播放的特定歌曲时。 但是,在这里我想获得默认视频以及水平列表视图。当我点击一个特定的视频时,它应该被播放。 如何获取默认视频以及列表视图。

XAML 代码:

    <phone:PhoneApplicationPage
    x:Class="PhoneApp1.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
   xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   xmlns:delay="clr-namespace:Delay;assembly=PhonePerformance"
   mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
   FontFamily="{StaticResource PhoneFontFamilyNormal}"
   FontSize="{StaticResource PhoneFontSizeNormal}"
   Foreground="{StaticResource PhoneForegroundBrush}"
   SupportedOrientations="Portrait" Orientation="Portrait"
   shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

 <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="Teluguone" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="Songs" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

 <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

        <MediaElement x:Name="player" AutoPlay="True" Margin="0,0,0,282"/>

        <ScrollViewer HorizontalScrollBarVisibility="Hidden" Height="Auto" Margin="-60,411,-93,10"  >
            <ListBox x:Name="videosongList" ScrollViewer.HorizontalScrollBarVisibility="Auto"
         ScrollViewer.VerticalScrollBarVisibility="Disabled" Height="200" Width="1000" SelectionChanged="videosongList_SelectionChanged" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,50,0,0"  Orientation="Horizontal">
                            <Image  x:Name="img1" Source="{Binding songpic}"  ></Image>

                            <TextBlock Text="{Binding songname}"  TextWrapping="NoWrap"  VerticalAlignment="Bottom"
                                       FontSize="20" />


                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <ListBox.ItemsPanel >
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"></StackPanel>

                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
        </ScrollViewer>
    </Grid>
</Grid>

XAML.cs 代码:

namespace PhoneApp1
   {
        public partial class MainPage : PhoneApplicationPage
       {
          public MainPage()
        {
             InitializeComponent();
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            // is there network connection available
             if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("No network connection available!");
                return;
            }
            // start loading XML-data
            WebClient downloader = new WebClient();
            Uri uri = new Uri("http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6", UriKind.Absolute);
            downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(VideosongsDownloaded);
            downloader.DownloadStringAsync(uri);
          }

          void VideosongsDownloaded(object sender, DownloadStringCompletedEventArgs e)
    {
            if (e.Result == null || e.Error != null)
            {
                MessageBox.Show("There was an error downloading the XML-file!");
            }
            else
            {
                // Deserialize if download succeeds
                XDocument document = XDocument.Parse(e.Result);
                XmlSerializer serializer = new XmlSerializer(typeof(videosongs));
                videosongs videosongs = (videosongs)serializer.Deserialize(document.CreateReader());
                videosongList.ItemsSource = videosongs.Collection;
            }
        }

    private async void videosongList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        Songsdetails song = (Songsdetails)videosongList.SelectedItem;


        var url = await YouTube.GetVideoUriAsync(song.songcode, YouTubeQuality.Quality480P);
        player.Source = url.Uri;
    }
}

}

任何人都请给我任何关于让默认视频与水平列表视图一起播放的建议。 非常感谢。

【问题讨论】:

    标签: windows-phone-8


    【解决方案1】:

    您是否尝试使用来自CodeplexYoutube 类播放Youtube 视频。

    Youtube Class

    否则您可以参考 msdn 中的示例:

    Youtube Video sample

    【讨论】:

    • 谢谢先生。我指的是Youtube课程
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多