Exemple #1
0
        private void UpdateVideoElement()
        {
            if (settings == null)
            {
                settings = new VideoSettings();
                settings = settings.Load();
            }

            SPFolder folder = null;

            //SPWeb web = null;

            videoField = (HTML5VideoField)ItemFieldValue;

            if (videoField != null && videoField.WebId != Guid.Empty && videoField.ItemId != Guid.Empty)
            {
                using (SPWeb web = SPContext.Current.Site.OpenWeb(videoField.WebId))
                {
                    if (web.Exists)
                    {
                        folder = web.GetFolder(videoField.ItemId);

                        if (folder.Exists)
                        {
                            BuildVideoControl(folder, web);
                        }
                        else
                        {
                            video.Visible = false;
                        }
                    }
                    else
                    {
                        video.Visible = false;
                    }
                }
            }
        }
Exemple #2
0
        protected override void CreateChildControls()
        {
            this.DisableInputFieldLabel = true;
            base.ControlMode            = SPContext.Current.FormContext.FormMode;
            base.CreateChildControls();


            videoField = (HTML5VideoField)ItemFieldValue;

            if (videoField == null)
            {
                videoField = new HTML5VideoField();
            }

            settings = new VideoSettings();
            settings = settings.Load();

            SPFolder folder = null;

            //SPWeb web = null;

            //image = (Hemrika.SharePresence.Html5.WebControls.Image)this.TemplateContainer.FindControl("html_image");
            videoPicker = (HTML5VideoPicker)this.TemplateContainer.FindControl("VideoPicker");
            video       = (Hemrika.SharePresence.Html5.WebControls.Video) this.TemplateContainer.FindControl("html_video");

            if (!ChildControlsCreated)
            {
                if (base.ControlMode == SPControlMode.Edit || base.ControlMode == SPControlMode.New)
                {
                    if (!Page.IsCallback)
                    {
                        HTML5VideoPropertyBag properties = new HTML5VideoPropertyBag();

                        if (folder != null)
                        {
                            properties.ItemId = folder.UniqueId;
                            properties.WebId  = folder.ParentWeb.ID;
                            properties.ListId = folder.ParentListId;
                        }
                        else
                        {
                            properties.WebId  = SPContext.Current.Web.ID;
                            properties.ListId = SPContext.Current.ListId;
                            properties.ItemId = SPContext.Current.ListItem.UniqueId;
                        }

                        if (videoPicker != null)
                        {
                            upload = (HyperLink)videoPicker.FindControl("upload");

                            if (upload != null)
                            {
                                upload.NavigateUrl = String.Format(upload.NavigateUrl, video.ClientID, videoPicker.ClientID, base.Web.ID);
                            }

                            videoPicker.OnValueChangedClientScript = "UpdateVideoAfterDialog('" + video.ClientID + "','" + videoPicker.ClientID + "');";
                            videoPicker.AfterCallbackClientScript  = "UpdateVideoAfterDialog('" + video.ClientID + "','" + videoPicker.ClientID + "');";

                            if (folder != null)
                            {
                                HTML5VideoPickerEntity entity = new HTML5VideoPickerEntity(folder.Item);

                                videoPicker.CustomProperty = properties.ToString();
                                videoPicker.Entities.Add(entity);
                                videoPicker.UpdateEntities(videoPicker.Entities);
                            }
                        }
                    }
                }

                if (video != null)
                {
                    videoField = (HTML5VideoField)ItemFieldValue;

                    if (videoField != null)
                    {
                        if (!Page.ClientScript.IsClientScriptIncludeRegistered("Video"))
                        {
                            Page.ClientScript.RegisterClientScriptInclude(typeof(HTML5VideoControl), "Video", "/_layouts/Hemrika/Content/js/video.js");
                        }

                        CssRegistration.Register("/_layouts/Hemrika/Content/css/video-js.css");

                        if (!Page.ClientScript.IsClientScriptBlockRegistered("VideoFlash"))
                        {
                            Page.ClientScript.RegisterClientScriptBlock(typeof(HTML5VideoControl), "VideoFlash", "_V_.options.flash.swf = \"" + ItemContext.Site.Url + "/_layouts/Hemrika/Content/js/video-js.swf\";", true);
                        }

                        if (videoField.WebId != Guid.Empty && videoField.ItemId != Guid.Empty)
                        {
                            using (SPWeb web = SPContext.Current.Site.OpenWeb(videoField.WebId))
                            {
                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.ItemId);
                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                                else
                                {
                                    video.Visible = false;
                                }
                            }
                        }
                        else
                        {
                            bool useRoot = false;
                            using (SPWeb web = SPContext.Current.Site.OpenWeb(videoField.Src))
                            {
                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.Src);

                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                                else
                                {
                                    useRoot = true;
                                }
                            }

                            if (useRoot)
                            {
                                SPWeb web = SPContext.Current.Site.RootWeb;

                                if (web.Exists)
                                {
                                    folder = web.GetFolder(videoField.Src);

                                    if (folder.Exists)
                                    {
                                        BuildVideoControl(folder, web);
                                    }
                                    else
                                    {
                                        video.Visible = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //ChildControlsCreated = true;
        }