protected void Page_Load(object sender, EventArgs e) { //available querystring values for context info (id, language, version, database) try { //get the current item and database currentDB = Sitecore.Configuration.Factory.GetDatabase("master"); currentItem = new VideoItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]); Item acct = currentItem.videoItem.Parent.Parent; //if current parent isn't the account then it's the parent of the folder if (!acct.TemplateName.Equals("Account Folder")) { acct = acct.Parent; } accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database); bc = new BCAPI(accountItem.PublisherID); if (!currentItem.ThumbnailURL.Equals("")) { pnlThumb.Visible = true; imgThumb.ImageUrl = currentItem.ThumbnailURL; } if (!currentItem.VideoStillURL.Equals("")) { pnlStill.Visible = true; imgStill.ImageUrl = currentItem.VideoStillURL; } } catch (Exception ex) { ltlError.Text = ex.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { //available querystring values for context info (id, language, version, database) try { //get the current item and database currentDB = Sitecore.Configuration.Factory.GetDatabase("master"); currentItem = new VideoItem(currentDB.Items[HttpContext.Current.Request.QueryString["id"].ToString()]); Item acct = currentItem.videoItem.Parent.Parent; //if current parent isn't the account then it's the parent of the folder if (!acct.TemplateName.Equals("Account Folder")) { acct = acct.Parent; } accountItem = new AccountItem(acct.ID, acct.InnerData, acct.Database); bc = new BCAPI(accountItem.PublisherID); //set the form values for the video if (!IsPostBack) { loadFormWithCurrentValues(); } //show the video id ltlVideoID.Text = currentItem.VideoID.ToString(); //show the video upload status RPCResponse<UploadStatusEnum> rpcr = bc.GetUploadStatus(currentItem.VideoID); ltlStatus.Text = rpcr.result.ToString(); ltlCreation.Text = currentItem.CreationDate.ToString("MMMM d, yyyy"); ltlModified.Text = currentItem.LastModifiedDate.ToString("MMMM d, yyyy"); ltlPublished.Text = currentItem.PublishedDate.ToString("MMMM d, yyyy"); try { long milliseconds = currentItem.Length; string lengthText = ""; long hours = (milliseconds / 60000000); if (hours >= 1) { milliseconds -= hours * 60000000; lengthText += hours + " hours, "; } long mins = (milliseconds / 60000); if (mins >= 1) { milliseconds -= mins * 60000; lengthText += mins + " minutes, "; } long secs = (milliseconds / 1000); if (secs >= 1) { milliseconds -= secs * 1000; lengthText += secs + " seconds"; } ltlLength.Text = lengthText; } catch(Exception ex){ } ltlPlays.Text = currentItem.PlaysTotal.ToString(); ltlPlaysTrailing.Text = currentItem.PlaysTrailingWeek.ToString(); } catch (Exception ex) { ltlError.Text = ex.ToString(); } }
/// <summary> /// This method will import / update a list of videos into the Brightcove Video Library /// </summary> /// <param name="Videos"> /// The Videos to import / update /// </param> /// <returns> /// returns a list of the new videos imported /// </returns> public static UpdateInsertPair<VideoItem> ImportToSitecore(this AccountItem account, List<BCVideo> Videos, UpdateType utype) { UpdateInsertPair<VideoItem> uip = new UpdateInsertPair<VideoItem>(); //set all BCVideos into hashtable for quick access Hashtable ht = new Hashtable(); foreach (VideoItem exVid in account.VideoLib.Videos) { if (!ht.ContainsKey(exVid.VideoID.ToString())) { //set as string, Item pair ht.Add(exVid.VideoID.ToString(), exVid); } } //Loop through the data source and add them foreach (BCVideo vid in Videos) { try { //remove access filter using (new Sitecore.SecurityModel.SecurityDisabler()) { VideoItem currentItem; //if it exists then update it if (ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.UPDATE))) { currentItem = (VideoItem)ht[vid.id.ToString()]; //add it to the new items uip.UpdatedItems.Add(currentItem); using (new EditContext(currentItem.videoItem, true, false)) { SetVideoFields(ref currentItem.videoItem, vid); } } //else just add it else if (!ht.ContainsKey(vid.id.ToString()) && (utype.Equals(UpdateType.BOTH) || utype.Equals(UpdateType.NEW))) { //Create new item TemplateItem templateType = account.Database.Templates["Modules/Brightcove/Brightcove Video"]; currentItem = new VideoItem(account.VideoLib.videoLibraryItem.Add(vid.name.StripInvalidChars(), templateType)); //add it to the new items uip.NewItems.Add(currentItem); using (new EditContext(currentItem.videoItem, true, false)) { SetVideoFields(ref currentItem.videoItem, vid); } } } } catch (System.Exception ex) { //HttpContext.Current.Response.Write(vid.name + "<br/>"); throw new Exception("Failed on video: " + vid.name + ". " + ex.ToString()); } } return uip; }
protected void SetVideoPlayer() { VideoItem vp = new VideoItem(currentDB.Items[ddlVideo.SelectedValue]); vpPlayer.PlayerID = currentItem.PlayerID; vpPlayer.VideoID = vp.VideoID; vpPlayer.PlayerName = currentItem.Name; vpPlayer.Height = currentItem.Height; vpPlayer.Width = currentItem.Width; if (chkAutoStart.Checked) { vpPlayer.AutoStart = true; } vpPlayer.WMode = ddlWMode.SelectedValue; IEnumerable<string> selected = from li in cblPlaylist.Items.Cast<ListItem>() where li.Selected == true select li.Value; vpPlayer.VideoList = -1; vpPlayer.PlaylistCombos.Clear(); vpPlayer.PlaylistTabs.Clear(); vpPlayer.CssClass = "BrightcoveExperience"; WMode wmode = WMode.Window; try { wmode = (WMode)Enum.Parse(wmode.GetType(), ddlWMode.SelectedValue, true); }catch{} switch (currentItem.PlaylistType) { case PlayerPlaylistType.VideoList: if (selected.Count() > 0) { PlaylistItem p = new PlaylistItem(currentDB.Items[selected.First()]); vpPlayer.VideoList = p.PlaylistID; pnlVideo.Visible = false; } break; case PlayerPlaylistType.Tabbed: List<long> pids = new List<long>(); foreach (string pID in selected) { PlaylistItem p = new PlaylistItem(currentDB.Items[pID]); vpPlayer.PlaylistTabs.Add(new PlaylistTab(p.PlaylistID)); pids.Add(p.PlaylistID); } pnlVideo.Visible = false; break; case PlayerPlaylistType.ComboBox: List<long> cpids = new List<long>(); foreach (string pID in selected) { PlaylistItem p = new PlaylistItem(currentDB.Items[pID]); vpPlayer.PlaylistCombos.Add(new PlaylistCombo(p.PlaylistID)); cpids.Add(p.PlaylistID); } pnlVideo.Visible = false; break; case PlayerPlaylistType.None: pnlPlaylist.Visible = false; break; } }
public static string GetEmbedCode(this PlayerItem player, VideoItem video, string BackgroundColor, bool AutoStart, WMode WMode, string objectTagID, Dictionary<string,string> objectParams) { return GetEmbedCode(player, video, -1, null, BackgroundColor, AutoStart, WMode, objectTagID, objectParams); }
public static string GetEmbedCode(this PlayerItem player, VideoItem video, string BackgroundColor, bool AutoStart, WMode WMode, string objectTagID) { return GetEmbedCode(player, video, BackgroundColor, AutoStart, WMode, objectTagID, new Dictionary<string, string>()); }
public static string GetEmbedCode(this PlayerItem player, VideoItem video, string BackgroundColor, bool AutoStart, WMode WMode) { return GetEmbedCode(player, video, BackgroundColor, AutoStart, WMode, CreateEmbedID()); }
public static string GetEmbedCode(this PlayerItem player, VideoItem video, string BackgroundColor, bool AutoStart) { return GetEmbedCode(player, video, BackgroundColor, AutoStart, WMode.Window); }
public static string GetEmbedCode(this PlayerItem player, VideoItem video, string BackgroundColor) { return GetEmbedCode(player, video, BackgroundColor, false); }
//based on video public static string GetEmbedCode(this PlayerItem player, VideoItem video) { return GetEmbedCode(player, video, "#ffffff"); }
/// <summary> /// This will build an html object tag based on the information provided /// </summary> /// <param name="player">The player defined under BrightcoveSDK.SitecoreUtil</param> /// <param name="objectTagID">The HTML Object ID Tag</param> /// <param name="video">The video defined under BrightcoveSDK.SitecoreUtil</param> /// <param name="PlaylistID">A Playlist ID for a single playlist video player</param> /// <param name="PlaylistIDs">The List of Playlist IDs for a multi playlist video player</param> /// <param name="BackgroundColor">The Hex Value in the form: #ffffff</param> /// <param name="AutoStart">A flag to cause the video to automatically start playing</param> /// <param name="WMode">The wmode </param> /// <returns></returns> private static string GetEmbedCode(this PlayerItem player, VideoItem video, long PlaylistID, List<long> PlaylistIDs, string BackgroundColor, bool AutoStart, WMode WMode, string objectTagID, Dictionary<string, string> objectParams) { long videoID = (video != null) ? video.VideoID : -1; return BrightcoveSDK.Utils.EmbedCode.GetEmbedCode(player.PlayerID, videoID, player.PlaylistType, PlaylistID, PlaylistIDs, player.Height, player.Width, BackgroundColor, AutoStart, WMode, objectTagID, objectParams); }
/// <summary> /// this makes sure you've selected an item from the video treeview /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected override void OnOK(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull(args, "args"); //get the selected playlist Item player = masterDB.Items[PlayerTreeview.Value]; if (player == null || !player.TemplateName.Equals(Constants.PlayerTemplate)) { SheerResponse.Alert("Select a player.", new string[0]); return; } //get the selected video Item video = masterDB.Items[VideoTreeview.Value]; string videoid = ""; if (video != null && video.TemplateName.Equals(Constants.VideoTemplate)) { VideoItem vid = new VideoItem(video); videoid = vid.VideoID.ToString(); } //get the selected playlists Item[] playlists = this.PlaylistTreeview.GetSelectedItems(); PlayerItem vpl = new PlayerItem(player); //set the playlists StringBuilder playlistStr = new StringBuilder(); int plistCount = 0; foreach (Item p in playlists) { if (p.TemplateName.Equals(Constants.PlaylistTemplate)) { PlaylistItem pl = new PlaylistItem(p); if (playlistStr.Length > 0) { playlistStr.Append(","); } playlistStr.Append(pl.PlaylistID.ToString()); plistCount++; } } //check if the player can handle the playlists selected if (vpl.PlaylistType.Equals(PlayerPlaylistType.None) && plistCount > 0) { SheerResponse.Alert("This player does not support playlists.\nTo deselect, select the Brightcove Media item.", new string[0]); return; } else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) && plistCount > 1) { SheerResponse.Alert("This player only supports one playlist.", new string[0]); return; } else if ((vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) || vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox) || vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)) && !videoid.Equals("")) { SheerResponse.Alert("This player does not support videos. \nTo deselect, select the Brightcove Media item.", new string[0]); return; } //build link then send it back StringBuilder mediaUrl = new StringBuilder(); mediaUrl.Append("<bc:VideoPlayerWebControl runat=\"server\" class=\"BrightcoveVideo\" xmlns:bc=\"http://www.sitecore.net/xhtml\" "); mediaUrl.Append("player=\"" + vpl.PlayerID + "\" "); mediaUrl.Append("autostart=\"" + chkAutoStart.Checked.ToString().ToLower() + "\" "); mediaUrl.Append("bgcolor=\"" + txtBGColor.Value + "\" "); mediaUrl.Append("wmode=\"" + WMode.SelectedItem.Header + "\" "); //determine what kind of playlist if (vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox)) { mediaUrl.Append("playlistcombo=\"" + playlistStr.ToString() + "\" "); }else if (vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)){ mediaUrl.Append("playlisttabs=\"" + playlistStr.ToString() + "\" "); }else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList)){ mediaUrl.Append("videolist=\"" + playlistStr.ToString() + "\" "); }else if (vpl.PlaylistType.Equals(PlayerPlaylistType.None)){ mediaUrl.Append("video =\"" + videoid + "\" "); } //close the tag mediaUrl.Append("></bc:VideoPlayer>"); //send it back if (this.Mode == "webedit") { SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(mediaUrl.ToString())); base.OnOK(sender, args); } else { SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(mediaUrl.ToString()) + "," + StringUtil.EscapeJavascriptString(player.DisplayName) + ")"); } }
/// <summary> /// this makes sure you've selected an item from the video treeview /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected override void OnOK(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull(args, "args"); //get the selected player Item player = masterDB.Items[PlayerTreeview.Value]; if (player == null || !player.TemplateName.Equals(Constants.PlayerTemplate)) { SheerResponse.Alert("Select a player.", new string[0]); return; } PlayerItem vpl = new PlayerItem(player); //get the selected video Item video = masterDB.Items[VideoTreeview.Value]; VideoItem vid = null; string videoid = ""; if (video != null && video.TemplateName.Equals(Constants.VideoTemplate)) { vid = new VideoItem(video); videoid = vid.VideoID.ToString(); } //get the selected playlists Item[] playlists = this.PlaylistTreeview.GetSelectedItems(); //set the playlists StringBuilder playlistStr = new StringBuilder(); int plistCount = 0; foreach (Item p in playlists) { if (p.TemplateName.Equals(Constants.PlaylistTemplate)) { PlaylistItem pl = new PlaylistItem(p); if (playlistStr.Length > 0) { playlistStr.Append(","); } playlistStr.Append(pl.PlaylistID.ToString()); plistCount++; } } //check if the player can handle the playlists selected if (vpl.PlaylistType.Equals(PlayerPlaylistType.None) && plistCount > 0) { SheerResponse.Alert("This player does not support playlists.\nTo deselect, select the Brightcove Media item.", new string[0]); return; } else if (vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) && plistCount > 1) { SheerResponse.Alert("This player only supports one playlist.", new string[0]); return; } else if ((vpl.PlaylistType.Equals(PlayerPlaylistType.VideoList) || vpl.PlaylistType.Equals(PlayerPlaylistType.ComboBox) || vpl.PlaylistType.Equals(PlayerPlaylistType.Tabbed)) && !videoid.Equals("")) { SheerResponse.Alert("This player does not support videos. \nTo deselect, select the Brightcove Media item.", new string[0]); return; } //use settings to determine what kind of modal window to use like thickbox or prettyphoto //id = {3EE8D1E1-1421-4546-8127-4D576FB8DA5F} ModalLinkSettings settings = ModalLinkSettings.GetModalLinkSettings(HttpContext.Current.Request.Url.Host.ToLower(), masterDB); StringBuilder sbAttr = new StringBuilder(); StringBuilder sbQstring = new StringBuilder(); if (settings != null) { foreach(Item child in settings.thisItem.GetChildren()){ if(child.TemplateName.Equals(Constants.LinkAttributeTemplate)){ sbAttr.Append(" " + child["Key"] + "=\"" + child["Value"] + "\""); } else if(child.TemplateName.Equals(Constants.LinkQuerystringTemplate)){ sbQstring.Append("&" + child["Key"] + "=" + child["Value"]); } } } //build link then send it back StringBuilder mediaUrl = new StringBuilder(); mediaUrl.Append("<a href=\"/BrightcoveVideo.ashx?video=" + videoid + "&player=" + vpl.PlayerID); mediaUrl.Append("&playlists=" + playlistStr.ToString()); mediaUrl.Append("&autoStart=" + chkAutoStart.Checked.ToString().ToLower()); mediaUrl.Append("&bgcolor=" + txtBGColor.Value.Replace("#", "")); mediaUrl.Append("&wmode=" + WMode.SelectedItem.Header); mediaUrl.Append("&oparams=" + txtOParams.Value); mediaUrl.Append(sbQstring.ToString()); mediaUrl.Append("&height=" + (vpl.Height + 20).ToString() + "&width=" + (vpl.Width + 20).ToString() + "\"" + sbAttr.ToString() + " title=\"" + txtLinkText.Value + "\">" + txtLinkText.Value + "</a>"); if (this.Mode == "webedit") { SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(mediaUrl.ToString())); base.OnOK(sender, args); } else { SheerResponse.Eval("scCloseLink(" + StringUtil.EscapeJavascriptString(mediaUrl.ToString()) + ")"); } }
/// <summary> /// This will build an html object tag based on the information provided /// </summary> /// <param name="player">The player defined under BrightcoveSDK.SitecoreUtil</param> /// <param name="objectTagID">The HTML Object ID Tag</param> /// <param name="video">The video defined under BrightcoveSDK.SitecoreUtil</param> /// <param name="PlaylistID">A Playlist ID for a single playlist video player</param> /// <param name="PlaylistIDs">The List of Playlist IDs for a multi playlist video player</param> /// <param name="BackgroundColor">The Hex Value in the form: #ffffff</param> /// <param name="AutoStart">A flag to cause the video to automatically start playing</param> /// <param name="WMode">The wmode </param> /// <returns></returns> private static string GetEmbedCode(this PlayerItem player, VideoItem video, long PlaylistID, List<long> PlaylistIDs, string BackgroundColor, bool AutoStart, WMode WMode, string objectTagID) { StringBuilder embed = new StringBuilder(); if (player != null) { //this one works embed.AppendLine("<!-- Start of Brightcove Player -->"); embed.AppendLine(""); embed.AppendLine("<div style=\"display:none\"></div>"); embed.AppendLine("<script language=\"JavaScript\" type=\"text/javascript\" src=\"http://admin.brightcove.com/js/BrightcoveExperiences.js\"></script>"); embed.AppendLine("<object id=\"" + objectTagID + "\" class=\"BrightcoveExperience\">"); embed.AppendLine("<param name=\"bgcolor\" value=\"" + BackgroundColor + "\" />"); embed.AppendLine("<param name=\"width\" value=\"" + player.Width.ToString() + "\" />"); embed.AppendLine("<param name=\"height\" value=\"" + player.Height.ToString() + "\" />"); embed.AppendLine("<param name=\"playerID\" value=\"" + player.PlayerID + "\" />"); //add in video ids or playlist ids if (player.PlaylistType.Equals(PlayerPlaylistType.None) && video != null) { embed.AppendLine("<param name=\"@videoPlayer\" value=\"" + video.VideoID + "\"/>"); } else if (player.PlaylistType.Equals(PlayerPlaylistType.Tabbed) && PlaylistIDs != null) { embed.AppendLine("<param name=\"@playlistTabs\" value=\"" + PlaylistIDs.ToDelimString(",") + "\"/>"); } else if (player.PlaylistType.Equals(PlayerPlaylistType.ComboBox) && PlaylistIDs != null) { embed.AppendLine("<param name=\"@playlistCombo\" value=\"" + PlaylistIDs.ToDelimString(",") + "\"/>"); } else if (player.PlaylistType.Equals(PlayerPlaylistType.VideoList) && PlaylistID != -1) { embed.AppendLine("<param name=\"@videoList\" value=\"" + PlaylistID.ToString() + "\"/>"); } embed.AppendLine("<param name=\"isVid\" value=\"true\" />"); embed.AppendLine("<param name=\"autoStart\" value=\"" + AutoStart.ToString().ToLower() + "\" />"); embed.AppendLine("<param name=\"isUI\" value=\"true\" />"); embed.AppendLine("<param name=\"dynamicStreaming\" value=\"true\" />"); embed.AppendLine("<param name=\"wmode\" value=\"" + WMode.ToString() + "\" /> "); embed.AppendLine("</object>"); embed.AppendLine(""); embed.AppendLine("<!-- End of Brightcove Player -->"); } return embed.ToString(); }