Initializing Youtube PL code behind

2 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    7 posts
    Member since:
    Feb 2015

    Posted 13 Mar 2015 Link to this post

    Hi,

    I am working code-behind and have a condition.

    If Ok => read a playlist
    if NotOK => read a single video

     if (myCondition)
                {
                    RadMediaPlayer1.Sources.Add(new MediaPlayerSource() { Path = "https://www.youtube.com/watch?v=C4gcySKN16E" });
                }
                else
                {                
                    RadMediaPlayer1.PlaylistSettings.YouTubePlaylist = MyYoutubePL;
                    RadMediaPlayer1.PlaylistSettings.Position = MediaPlayerPlaylistPosition.Horizontal;
                    RadMediaPlayer1.PlaylistSettings.Mode = MediaPlayerPlaylistMode.Buttons;
                    RadMediaPlayer1.PlaylistSettings.ButtonsTrigger = MediaPlayerScrollButtonsTrigger.Hover;
                }

    When myCondition is true, all works perfecly, the single video file is attached to the player

    but if myCondition is false : nothing happens, I can't see any Playlist or video...

    Any idea ?
  2. Eyup
    Admin
    Eyup avatar
    3013 posts

    Posted 18 Mar 2015 Link to this post

    Hi Arnaud,

    Can you please verify whether you are configuring the player sources during the Page_init event handler of the player?
    http://www.telerik.com/support/code-library/programmatic-creation-and-configuration-of-the-media-player-control

    The best solution in your scenario would be to define declaratively two RadMediaPlayers - one with single source and the other one with Playlist. Then, depending on some user interaction or selection you can hide one of them using its Visible property.

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top