Search code examples
youtubeembedyoutube-apiyoutube-channels

YouTube channel video player with playlist


I am looking for creating youtube section on my site, where the user could plug in their "youtube channel name" and it will show a playlist/player box on their profile.

What I want in this playlist/player box is that it should play the default video on load; the list of other videos in the channel could be on the left side or on the bottom.
Clicking on another video will start playing that video.

I know there are lot many widget and tools available for doing but I am not getting the specific thing that I am looking for.
Can anyone point me to a proper page/tutorial to do this?

Thanks in advance. :)


Solution

  • If you're using ASP.NET, it's super easy with Linq. Just consume the YouTube video feed and then do whatever you want with it:

    Here's the call you make to get the list of videos from a channel:

    http://gdata.youtube.com/feeds/api/users/YOUTUBE_USERNAME_HERE/uploads?orderby=updated

    And here's some example code:

        var url = FeedUrl;
        XDocument rss = XDocument.Load(url);
    
        var videos = from i in rss.Root.Elements("{http://www.w3.org/2005/Atom}entry")
                select new
                {
                    Title = i.Element("{http://www.w3.org/2005/Atom}title").Value,
                    URL = i.Element("{http://www.w3.org/2005/Atom}link").Attribute("href").Value
                };
    

    You can do what you want with the feed at that point, such as convert the video URLs into something embeddable, and so forth.

    Good luck!

    Best,

    -Auri