protected override void CreateChildControls()
        {
            // Init config
            using (SPWeb web = SPContext.Current.Web)
            {
                if (_cachedConfigProvider == null)
                {
                    _cachedConfigProvider = new Hashtable();
                }

                if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty)
                {
                    this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url];
                }
                else
                {
                    // Init Brightcove site settings
                    string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl,
                        KeyVideoPlayerId, KeyPlaylistPlayerId };
                    bool madeChanges = false;

                    foreach (string key in keys)
                    {
                        if (!web.AllProperties.ContainsKey(key))
                        {
                            web.AllProperties.Add(key, string.Empty);
                            madeChanges = true;
                        }
                    }

                    if (web.AllProperties[KeyReadUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library";
                        madeChanges = true;
                    }

                    if (web.AllProperties[KeyWriteUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post";
                        madeChanges = true;
                    }

                    // Get Brightcove settings
                    VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig();

                    this.PublisherId = bvcConfig.PublisherId;
                    this.ReadToken = bvcConfig.ReadToken;
                    this.WriteToken = bvcConfig.WriteToken;
                    this.ReadUrl = bvcConfig.ReadUrl;
                    this.WriteUrl = bvcConfig.WriteUrl;
                    this.DefaultVideoPlayerId = bvcConfig.DefaultVideoPlayerId;
                    this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId;
                    this.configProvider = this;

                    // Only write the config if the requested site matches the current site
                    if (_cachedConfigProvider.ContainsKey(web.Url))
                    {
                        _cachedConfigProvider[web.Url] = this.configProvider;
                    }
                    else
                    {
                        _cachedConfigProvider.Add(web.Url, this.configProvider);
                    }

                    if (madeChanges)
                    {
                        web.AllowUnsafeUpdates = true;
                        web.Update();
                    }
                }
            }

            // Handle AJAX call to get a video list
            if (!this._isAsyncCall)
            {
                this._isAsyncCall = AsyncVideoList();

                //if (!this._isAsyncCall)
                //{
                //    this._isAsyncCall = AsyncChooser();
                //}
            }

            this.ChromeType = PartChromeType.None;
        }
Esempio n. 2
0
        private void GetOldConfiguration()
        {
            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                SPWeb web = site.OpenWeb();

                if (_cachedConfigProvider == null)
                {
                    _cachedConfigProvider = new Hashtable();
                }

                if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty)
                {
                    this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url];
                }
                else
                {
                    // Init Brightcove site settings
                    string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl,
                                                   KeyVideoPlayerId, KeyPlaylistPlayerId };
                    bool madeChanges = false;

                    foreach (string key in keys)
                    {
                        if (!web.AllProperties.ContainsKey(key))
                        {
                            web.AllProperties.Add(key, string.Empty);
                            madeChanges = true;
                        }
                    }

                    if (web.AllProperties[KeyReadUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library";
                        madeChanges = true;
                    }

                    if (web.AllProperties[KeyWriteUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post";
                        madeChanges = true;
                    }

                    // Get Brightcove settings
                    VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig();

                    this.PublisherId             = bvcConfig.PublisherId;
                    this.ReadToken               = bvcConfig.ReadToken;
                    this.WriteToken              = bvcConfig.WriteToken;
                    this.ReadUrl                 = bvcConfig.ReadUrl;
                    this.WriteUrl                = bvcConfig.WriteUrl;
                    this.DefaultVideoPlayerId    = bvcConfig.DefaultVideoPlayerId;
                    this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId;
                    this.configProvider          = this;

                    // Only write the config if the requested site matches the current site
                    if (_cachedConfigProvider.ContainsKey(web.Url))
                    {
                        _cachedConfigProvider[web.Url] = this.configProvider;
                    }
                    else
                    {
                        _cachedConfigProvider.Add(web.Url, this.configProvider);
                    }

                    if (madeChanges)
                    {
                        web.AllowUnsafeUpdates = true;
                        web.Update();
                    }
                }
            }
        }
        protected override void CreateChildControls()
        {
            // Init config
            using (SPWeb web = SPContext.Current.Web)
            {
                if (_cachedConfigProvider == null)
                {
                    _cachedConfigProvider = new Hashtable();
                }

                if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty)
                {
                    this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url];
                }
                else
                {
                    // Init Brightcove site settings
                    string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl,
                                                   KeyVideoPlayerId, KeyPlaylistPlayerId };
                    bool madeChanges = false;

                    foreach (string key in keys)
                    {
                        if (!web.AllProperties.ContainsKey(key))
                        {
                            web.AllProperties.Add(key, string.Empty);
                            madeChanges = true;
                        }
                    }

                    if (web.AllProperties[KeyReadUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library";
                        madeChanges = true;
                    }

                    if (web.AllProperties[KeyWriteUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post";
                        madeChanges = true;
                    }

                    // Get Brightcove settings
                    VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig();

                    this.PublisherId             = bvcConfig.PublisherId;
                    this.ReadToken               = bvcConfig.ReadToken;
                    this.WriteToken              = bvcConfig.WriteToken;
                    this.ReadUrl                 = bvcConfig.ReadUrl;
                    this.WriteUrl                = bvcConfig.WriteUrl;
                    this.DefaultVideoPlayerId    = bvcConfig.DefaultVideoPlayerId;
                    this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId;
                    this.configProvider          = this;

                    // Only write the config if the requested site matches the current site
                    if (_cachedConfigProvider.ContainsKey(web.Url))
                    {
                        _cachedConfigProvider[web.Url] = this.configProvider;
                    }
                    else
                    {
                        _cachedConfigProvider.Add(web.Url, this.configProvider);
                    }

                    if (madeChanges)
                    {
                        web.AllowUnsafeUpdates = true;
                        web.Update();
                    }
                }
            }

            // Handle AJAX call to get a video list
            if (!this._isAsyncCall)
            {
                this._isAsyncCall = AsyncVideoList();

                //if (!this._isAsyncCall)
                //{
                //    this._isAsyncCall = AsyncChooser();
                //}
            }

            this.ChromeType = PartChromeType.None;
        }
        private void GetOldConfiguration() {

            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                SPWeb web = site.OpenWeb();

                if (_cachedConfigProvider == null)
                {
                    _cachedConfigProvider = new Hashtable();
                }

                if (_cachedConfigProvider.ContainsKey(web.Url) && !this._isDirty)
                {
                    this.configProvider = (IVideoCloudConfig)_cachedConfigProvider[web.Url];
                }
                else
                {
                    // Init Brightcove site settings
                    string[] keys = new string[] { KeyPublisherId, KeyReadToken, KeyWriteToken, KeyReadUrl, KeyWriteUrl, 
                        KeyVideoPlayerId, KeyPlaylistPlayerId };
                    bool madeChanges = false;

                    foreach (string key in keys)
                    {
                        if (!web.AllProperties.ContainsKey(key))
                        {
                            web.AllProperties.Add(key, string.Empty);
                            madeChanges = true;
                        }
                    }

                    if (web.AllProperties[KeyReadUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyReadUrl] = "http://api.brightcove.com/services/library";
                        madeChanges = true;
                    }

                    if (web.AllProperties[KeyWriteUrl].Equals(string.Empty))
                    {
                        web.AllProperties[KeyWriteUrl] = "http://api.brightcove.com/services/post";
                        madeChanges = true;
                    }

                    // Get Brightcove settings
                    VideoConfig.VideoConfig bvcConfig = new VideoConfig.VideoConfig();

                    this.PublisherId = bvcConfig.PublisherId;
                    this.ReadToken = bvcConfig.ReadToken;
                    this.WriteToken = bvcConfig.WriteToken;
                    this.ReadUrl = bvcConfig.ReadUrl;
                    this.WriteUrl = bvcConfig.WriteUrl;
                    this.DefaultVideoPlayerId = bvcConfig.DefaultVideoPlayerId;
                    this.DefaultPlaylistPlayerId = bvcConfig.DefaultPlaylistPlayerId;
                    this.configProvider = this;

                    // Only write the config if the requested site matches the current site
                    if (_cachedConfigProvider.ContainsKey(web.Url))
                    {
                        _cachedConfigProvider[web.Url] = this.configProvider;
                    }
                    else
                    {
                        _cachedConfigProvider.Add(web.Url, this.configProvider);
                    }

                    if (madeChanges)
                    {
                        web.AllowUnsafeUpdates = true;
                        web.Update();
                    }
                }
            }
        }
        private static VideoConfig.VideoConfig MakeProviderWebPart()
        {
            VideoConfig.VideoConfig provider = new VideoConfig.VideoConfig();

            provider.ChromeType = PartChromeType.None;
            provider.AllowConnect = true;
            provider.ExportMode = WebPartExportMode.All;
            provider.Title = "Brightcove Video Cloud Config";
            provider.PublisherId = "";  // Add your publisher ID here
            provider.ReadToken = "";    // Add your read tokens here, comma separated
            provider.WriteToken = "";   // Add your write tokens here, comma separated

            return provider;
        }