using System;
using System.Web.UI;
using CMS.ExtendedControls;
using CMS.GlobalHelper;
public partial class CMSInlineControls_YouTubeControl : InlineUserControl
{
#region "Properties"
///
/// Url of youtube media.
///
public string Url
{
get
{
return ValidationHelper.GetString(GetValue("Url"), "");
}
set
{
SetValue("Url", value);
}
}
///
/// Enable full screen for youtube player.
///
public bool Fs
{
get
{
return ValidationHelper.GetBoolean(GetValue("Fs"), false);
}
set
{
SetValue("Fs", value);
}
}
///
/// Enable auto play for youtube player.
///
public bool AutoPlay
{
get
{
return ValidationHelper.GetBoolean(GetValue("AutoPlay"), false);
}
set
{
SetValue("AutoPlay", value);
}
}
///
/// Enable loop for youtube player.
///
public bool Loop
{
get
{
return ValidationHelper.GetBoolean(GetValue("Loop"), false);
}
set
{
SetValue("Loop", value);
}
}
///
/// Enable relative videos in youtube player.
///
public bool Rel
{
get
{
return ValidationHelper.GetBoolean(GetValue("Rel"), false);
}
set
{
SetValue("Rel", value);
}
}
///
/// Width of youtube player.
///
public int Width
{
get
{
return ValidationHelper.GetInteger(GetValue("Width"), 0);
}
set
{
SetValue("Width", value);
}
}
///
/// Height of youtube player.
///
public int Height
{
get
{
return ValidationHelper.GetInteger(GetValue("Height"), 0);
}
set
{
SetValue("Height", value);
}
}
///
/// Control parameter.
///
public override string Parameter
{
get
{
return Url;
}
set
{
Url = value;
}
}
#endregion
#region "Page events"
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreRender(object sender, EventArgs e)
{
// Render YouTube preview only if Url is set
if (!string.IsNullOrEmpty(Url))
{
YouTubeVideoParameters ytParams = new YouTubeVideoParameters();
ytParams.Url = Url;
ytParams.FullScreen = Fs;
ytParams.AutoPlay = AutoPlay;
ytParams.Loop = Loop;
ytParams.RelatedVideos = Rel;
ytParams.Width = Width;
ytParams.Height = Height;
ltlYouTube.Text = MediaHelper.GetYouTubeVideo(ytParams);
}
}
#endregion
}