2014-09-10 3 views
0

J'ai analysé le flux RSS http://www.teluguone.com/videosongs/videoSongsXml.php?cat_id=6. Et affiché des chansons dans la vue Liste horizontale. Comme montré ci-dessous enter image description hereLecture vidéo par défaut dans Windows Phone 8

Lorsque je clique sur une chanson particulière, elle jouait dans l'espace ci-dessus. Mais, ici, je veux obtenir la vidéo par défaut avec affichage de la liste horizontale.Et lorsque je clique sur une vidéo en particulier, il devrait être joué. Comment obtenir la vidéo par défaut avec la vue Liste.

code 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> 

Code pour 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; 
    } 
} 

} 

Tout le monde s'il vous plaît me donner toute suggestion d'obtenir la vidéo par défaut en jouant avec liste horizontale vue. Merci beaucoup.

Répondre

0

Avez-vous essayé de lire des vidéos Youtube en utilisant la classe Youtube de Codeplex.

Youtube Class

ou bien vous pouvez consulter l'échantillon de msdn:

Youtube Video sample

+0

Merci sir.I classe Youtube référenceurs suis – deepu

+0

oki, le cas échéant question déposer ici. – Kulasangar