Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MediaPlayer > How to Play a Video from YouTube

Not answered How to Play a Video from YouTube

Feed from this thread
  • Posted on Nov 11, 2011 (permalink)

    Good Day All I want to play a video in YouTube using the Mediaplayer. My Xaml looks like this 

         <telerik:RadMediaPlayer Height="446"  HorizontalAlignment="Left" Name="SermonsPlayer" IsAutoPlaylistAdvance="True" IsAutoReverse="True"
    SelectedIndex="0" IsPlaylistVisible="True" VerticalAlignment="Top" Width="813" Grid.Row="1" >
              <telerik:RadMediaPlayer.ItemTemplate>
                  <DataTemplate>
                      <telerik:ContainerBinding.ContainerBindings>
                          <telerik:ContainerBindingCollection>
                              <telerik:ContainerBinding Binding="{Binding Source}" PropertyName="Source" />
                              <telerik:ContainerBinding PropertyName="ItemsSource"
                                      Binding="{Binding Source}" />
     
                          </telerik:ContainerBindingCollection>
                      </telerik:ContainerBinding.ContainerBindings>
                      <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock Margin="4"
                             VerticalAlignment="Center"
                             Text="{Binding Title}" />
                      </StackPanel>
                  </DataTemplate>
              </telerik:RadMediaPlayer.ItemTemplate>
     
          </telerik:RadMediaPlayer>

    and my class and the way i get data looks like this 
    public partial class VideoSermons : ChildWindow
       {
           public VideoSermons()
           {
               InitializeComponent();
               SermonsPlayer.ItemsSource = GetItems();
           }
     
           public static ObservableCollection<MediaItem> GetItems()
           {
               MediaItem item1 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=DYwIRy3_BVA",
                   Title = "Creflo Dollar - The Truth About Hell 1 of 3"
               };
               MediaItem item2 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=Tx8EhtxZrls",
           
                   Title = "Pastor Creflo Dollar - The Truth About Hell"
               };
               MediaItem item3 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=Z7zaj_S_6Dc",
        
                   Title = "Joel Osteen - Overcoming Anger"
               };
                 
     
               MediaItem item4 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=YVc-JsTmOHY&feature=related",
                
                   Title = "Creflo Dollar speaks about marriages (perfect mates)"
               };
                 
     
     
                   MediaItem item5 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=sG2bh0HyeBE&feature=related",
                 
                   Title = "Creflo Dollar-How to Avoid Fornication"
               };
     
     
                
                   MediaItem item6 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=4Zb3CSnemTg&feature=related",
               
                   Title = "TD Jakes - Relationships"
               };
     
     
     
     
                 
                      
                   MediaItem item7 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=rZpcRemufO4",
                  
                   Title = "T.D. Jakes 5 People In Your Life"
               };
                 
                            
                   MediaItem item8 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=WIRSYBMeW-0&feature=related",
                   
                   Title = "Joel Osteen - Having Mountain Moving Faith"
               };
                 
     
     
               MediaItem item9 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=tKE0WkbXPC0&feature=relmfu",
              
                   Title = "Remind God What He Said"
               };
                 
     
     
               MediaItem item10 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=5VNVI2tK7Zw&feature=related",
                 
                   Title = "Joel Osteen - Say 'NO' To Your Feelings"
               };
                 
     
     
               MediaItem item11 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=XskzFKpALrg",
                  
                   Title = "Resisting Temptation"
                    
               };
                 
               MediaItem item12 = new MediaItem
               {
                   Source = "http://www.youtube.com/watch?v=aU5kek3D-4I",
                   
                   Title = "Joel Osteen teaches Christians about PORK!"
               };
               ObservableCollection<MediaItem> items = new ObservableCollection<MediaItem>();
               items.Add(item1);
               items.Add(item2);
               items.Add(item3);
               items.Add(item4);
               items.Add(item5);
               items.Add(item6);
               items.Add(item7);
               items.Add(item8);
               items.Add(item9);
               items.Add(item10);
               items.Add(item11);
               items.Add(item12);
               return items;
           }
     
           public class MediaItem
           {
               public string Image { get; set; }
               public string Source { get; set; }
               public string Title { get; set; }
               public bool IsStreamingSource { get; set; }
           }
     
          
       }

    now i can load the Videos in a Playlist , but when clicking the Playlist the Video does not play , i get the Error 

    Failed to Open Media!

    Thanks 


    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Nov 16, 2011 (permalink)

    Hello Vuyiswa Maseko,

     The RadMediaPlayer wraps a collection of the Silverlight MediaElements. Unfortunately, you cannot use MediaElement to play youtube videos directly. You need to user source link point directly to the media file.
    You can check out this stackoverflow post for more info.

    All the best,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > MediaPlayer > How to Play a Video from YouTube
Related resources for "How to Play a Video from YouTube"

Silverlight MediaPlayer Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]