using System.Web; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; using CMS.SettingsProvider; public partial class CMSWebParts_Media_QuickTime : CMSAbstractWebPart { #region "Public properties" /// /// Gets or sets the value that indicates whether video is automatically activated. /// public bool AutoActivation { get { return ValidationHelper.GetBoolean(GetValue("AutoActivation"), false); } set { SetValue("AutoActivation", value); } } /// /// Gets or sets the URL of video to be displayed. /// public string VideoURL { get { return ValidationHelper.GetString(GetValue("VideoURL"), ""); } set { SetValue("VideoURL", value); } } /// /// Gets or sets the width of video. /// public int Width { get { return ValidationHelper.GetInteger(GetValue("Width"), 400); } set { SetValue("Width", value); } } /// /// Gets or sets the height of video. /// public int Height { get { return ValidationHelper.GetInteger(GetValue("Height"), 300); } set { SetValue("Height", value); } } /// /// Gets or sets the value that indicates whether the video is automatically started. /// public bool Autostart { get { return ValidationHelper.GetBoolean(GetValue("Autostart"), false); } set { SetValue("Autostart", value); } } /// /// Gets or sets the value that indicates whether video controller is displayed. /// public bool ShowControls { get { return ValidationHelper.GetBoolean(GetValue("ShowControls"), true); } set { SetValue("ShowControls", value); } } /// /// Gets or sets the value that indicates whether video after the end is automatically started again. /// public bool Loop { get { return ValidationHelper.GetBoolean(GetValue("Loop"), false); } set { SetValue("Loop", value); } } #endregion #region "Methods" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Reloads data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { if (CMSContext.ViewMode == ViewModeEnum.Design) { ltlPlaceholder.Text = "
" + GetString("global.herecomesvideo").ToUpperCSafe() + "
"; } else { // Auto activation hack if (AutoActivation) { ltlPlaceholder.Text = "
"; // Register external script ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Media/QuickTime_files/video.js"); // Call function for video object insertion ltlScript.Text = BuildScriptBlock(); } else { ltlPlaceholder.Text = "
" + "" + "" + "" + //"" + "" + "" + "" + "" + "" + "" + "" + "" + //"" + GetString("Media.NotSupported") + "\n" + "" + "" + "
"; } } } } /// /// Creates a script block which loads a QuickTime video at runtime. /// /// Script block that will load a QuickTime video private string BuildScriptBlock() { string scriptBlock = string.Format("LoadQuickTime('QTPlaceholder_{0}', '{1}', {2}, {3}, '{4}', '{5}', '{6}', {7});", ltlScript.ClientID, HTMLHelper.HTMLEncode(URLHelper.ResolveUrl(VideoURL)), Width, Height, ShowControls.ToString().ToLowerCSafe(), Autostart.ToString().ToLowerCSafe(), Loop.ToString().ToLowerCSafe(), ScriptHelper.GetString(GetString("Media.NotSupported"))); return ScriptHelper.GetScript(scriptBlock); } #endregion }