New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Programmatic Creation

In some scenarios it is required to create the RadMediaPlayer control programmatically. Depending on some user interaction or selection, you can even build up the Playlist anew. The following example demonstrates a generic dynamic creation and configuration of the player and adds it to the main Controls collection. You can add it to a PlaceHolder or similar container control instead.

C#
protected void Page_Init(object sender, EventArgs e)
{
    BuildPlayer();
}
private void BuildPlayer()
{
    RadMediaPlayer player = new RadMediaPlayer()
        {
            ID = "RadMediaPlayer1",
            Height = Unit.Pixel(360),
            Width = Unit.Pixel(640),
            Skin = "Metro",
            AutoPlay = true,
            Title = "Video 1",
            Poster = "~/VideoPosters/poster1.jpg",
            Source = "~/Video/video1.mp4"
        };

    player.Load += (s, a) =>
    {
        player.TitleBar.ShareButton.Visible = false;
        player.ToolBar.HDButton.Visible = false;
    };

    Form.Controls.Add(player);
}

For creating the Playlist feature dynamicallyand to examine a bit more advanced scenario, you can check the Programmatic Creation Code-Library.

See Also

In this article
See Also
Not finding the help you need?
Contact Support