How to Play a Video from YouTube

4 posts, 0 answers
  1. Vuyiswa
    Vuyiswa avatar
    223 posts
    Member since:
    Jan 2010

    Posted 11 Nov 2011 Link to this post

    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:ContainerBinding Binding="{Binding Source}" PropertyName="Source" />
                              <telerik:ContainerBinding PropertyName="ItemsSource"
                                      Binding="{Binding Source}" />
                      <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                            <TextBlock Margin="4"
                             Text="{Binding Title}" />

    and my class and the way i get data looks like this 
    public partial class VideoSermons : ChildWindow
           public VideoSermons()
               SermonsPlayer.ItemsSource = GetItems();
           public static ObservableCollection<MediaItem> GetItems()
               MediaItem item1 = new MediaItem
                   Source = "",
                   Title = "Creflo Dollar - The Truth About Hell 1 of 3"
               MediaItem item2 = new MediaItem
                   Source = "",
                   Title = "Pastor Creflo Dollar - The Truth About Hell"
               MediaItem item3 = new MediaItem
                   Source = "",
                   Title = "Joel Osteen - Overcoming Anger"
               MediaItem item4 = new MediaItem
                   Source = "",
                   Title = "Creflo Dollar speaks about marriages (perfect mates)"
                   MediaItem item5 = new MediaItem
                   Source = "",
                   Title = "Creflo Dollar-How to Avoid Fornication"
                   MediaItem item6 = new MediaItem
                   Source = "",
                   Title = "TD Jakes - Relationships"
                   MediaItem item7 = new MediaItem
                   Source = "",
                   Title = "T.D. Jakes 5 People In Your Life"
                   MediaItem item8 = new MediaItem
                   Source = "",
                   Title = "Joel Osteen - Having Mountain Moving Faith"
               MediaItem item9 = new MediaItem
                   Source = "",
                   Title = "Remind God What He Said"
               MediaItem item10 = new MediaItem
                   Source = "",
                   Title = "Joel Osteen - Say 'NO' To Your Feelings"
               MediaItem item11 = new MediaItem
                   Source = "",
                   Title = "Resisting Temptation"
               MediaItem item12 = new MediaItem
                   Source = "",
                   Title = "Joel Osteen teaches Christians about PORK!"
               ObservableCollection<MediaItem> items = new ObservableCollection<MediaItem>();
               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!


  2. Petar Mladenov
    Petar Mladenov avatar
    3162 posts

    Posted 16 Nov 2011 Link to this post

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

  3. Chon
    Chon avatar
    7 posts
    Member since:
    Nov 2008

    Posted 20 Jan 2015 in reply to Petar Mladenov Link to this post

    Since this post is 3 years old now, I was wondering:

    Is it still not possible to play a youtube video directly from the mediaplayer element? 

    If it is possible, could you please provide me with some sample xaml demonstrating how to play a youtube video?

  4. Kiril Vandov
    Kiril Vandov avatar
    324 posts

    Posted 22 Jan 2015 Link to this post

    Hello Chon,

    YouTube uses FLV format for streaming the video, which is proprietary format and is unplayable by native Silverlight applications. This is a framework limitation and that is why the RadMediaPlayer is not able to play such videos. The RadMediaPlayer uses MedialElement internally and it could play almost everything that runs successfully in MediaElement.

    I hope this information helps.

    Kind regards,
    Kiril Vandov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top