Beispiel #1
0
        private void SetFieldControlValue(object value)
        {
            ArrayList       list       = new ArrayList();
            HTML5VideoField videoField = null;

            if (videoPicker != null)
            {
                if (this.ControlMode == SPControlMode.New && videoPicker.Entities.Count == 0)
                {
                    videoField = new HTML5VideoField();
                    HTML5VideoPickerEntity defaultEntity = this.videoPicker.ValidateEntity(new HTML5VideoPickerEntity()
                    {
                        Key = videoField.Src
                    });
                    if (defaultEntity != null)
                    {
                        list.Add(defaultEntity);
                    }
                    videoPicker.Entities.Clear();
                    videoPicker.UpdateEntities(list);
                }

                if (value != null)
                {
                    ArrayList              entities = new ArrayList();
                    HTML5VideoField        field    = (HTML5VideoField)value;
                    HTML5VideoPickerEntity entity   = new HTML5VideoPickerEntity(field);
                    entities.Add(entity);
                    videoPicker.UpdateEntities(entities);
                }
            }
        }
Beispiel #2
0
 public HTML5VideoPickerEntity(HTML5VideoField field)
 {
     this.WebId  = field.WebId;
     this.ListId = field.ListId;
     this.ItemId = field.ItemId;
     this.Src    = field.Src;
 }
Beispiel #3
0
        public override string GetFieldValueAsText(object value)
        {
            HTML5VideoField field = (HTML5VideoField)value;

            if (field != null)
            {
                return(field.ToString());
            }
            return(string.Empty);
        }
Beispiel #4
0
        public override void UpdateFieldValueInItem()
        {
            EnsureChildControls();

            if (videoPicker.Enabled)
            {
                videoPicker.Validate();
                if (videoPicker.Entities.Count > 0)
                {
                    PickerEntity entity = null;
                    if (videoPicker.ResolvedEntities.Count == 1)
                    {
                        entity = (PickerEntity)videoPicker.ResolvedEntities[0];
                    }
                    else
                    {
                        entity = (PickerEntity)videoPicker.Entities[0];
                    }

                    HTML5VideoPickerEntity videoEntity = new HTML5VideoPickerEntity(entity);

                    HTML5VideoField itemFieldValue = (HTML5VideoField)this.ItemFieldValue;

                    if (videoEntity.IsResolved)
                    {
                        if (itemFieldValue == null)
                        {
                            itemFieldValue = new HTML5VideoField();
                        }

                        itemFieldValue.Src    = videoEntity.Src;
                        itemFieldValue.ItemId = videoEntity.ItemId;
                        itemFieldValue.WebId  = videoEntity.WebId;
                        itemFieldValue.ListId = videoEntity.ListId;

                        this.ItemFieldValue = itemFieldValue;

                        UpdateVideoElement();
                    }
                }
            }
        }
Beispiel #5
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;
                    }
                }
            }
        }
Beispiel #6
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;
        }