/// <summary>
        /// Creates the JavaScript block and Flash div controls and adds them to the page
        /// </summary>
        protected override void CreateChildControls()
        {
            //Add the flash content panel to the page
            this.Controls.Clear();

            Panel vp = new Panel();

            vp.ID = this.ClientID;
            this.Controls.Add(vp);

            if (!VideoID.Equals(-1) || !PlayerID.Equals(-1))
            {
                //wmode
                WMode qWMode = BrightcoveSDK.WMode.Transparent;
                if (WMode.Equals(BrightcoveSDK.WMode.Opaque.ToString().ToLower()))
                {
                    qWMode = BrightcoveSDK.WMode.Opaque;
                }
                if (WMode.Equals(BrightcoveSDK.WMode.Window.ToString().ToLower()))
                {
                    qWMode = BrightcoveSDK.WMode.Window;
                }

                string  uniqueID  = "video_" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.FFFF");
                Literal litScript = new Literal();
                if (PlaylistTabs.Any())
                {
                    litScript.Text = EmbedCode.GetTabbedPlayerEmbedCode(PlayerID, VideoID, PlaylistTabs.GetValues(), Height, Width, BackColor, AutoStart, qWMode, uniqueID);
                }
                else if (PlaylistCombos.Any())
                {
                    litScript.Text = EmbedCode.GetComboBoxPlayerEmbedCode(PlayerID, VideoID, PlaylistCombos.GetValues(), Height, Width, BackColor, AutoStart, qWMode, uniqueID);
                }
                else if (VideoList != -1)
                {
                    EmbedCode.GetVideoListPlayerEmbedCode(PlayerID, VideoID, VideoList, Height, Width, BackColor, AutoStart, qWMode, uniqueID);
                }
                else
                {
                    litScript.Text = EmbedCode.GetVideoPlayerEmbedCode(PlayerID, VideoID, Height, Width, BackColor, AutoStart, qWMode, uniqueID);
                }

                Controls.Add(litScript);
            }
        }
        // Methods
        private void DoProcessRequest(HttpContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            //return DoProcessRequest(context, request, media);
            if (context != null)
            {
                NameValueCollection nvc = context.Request.QueryString;

                //player
                long qPlayer = 0;
                if (nvc.HasKey("player"))
                {
                    long.TryParse(nvc.Get("player"), out qPlayer);
                }
                PlayerItem p = PlayerLibraryItem.GetPlayer(qPlayer);
                if (p == null)
                {
                    context.Response.Write("The player is null"); return;
                }

                //video
                long qVideo = 0;
                if (nvc.HasKey("video"))
                {
                    long.TryParse(nvc.Get("video"), out qVideo);
                }

                //playlist ids
                long        qPlaylist    = 0;
                List <long> qPlaylistIds = new List <long>();
                if (nvc.HasKey("playlists"))
                {
                    string[] playlistids = context.Request.QueryString.Get("playlists").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    //if you only want a single
                    if (p.PlaylistType.Equals(PlayerPlaylistType.None))
                    {
                        if (playlistids.Any())
                        {
                            long.TryParse(playlistids[0], out qPlaylist);
                        }
                    }
                    else                         //you're looking for multiple
                    {
                        foreach (string id in playlistids)
                        {
                            long plist = -1;
                            if (long.TryParse(id, out plist))
                            {
                                qPlaylistIds.Add(plist);
                            }
                        }
                    }
                }

                //auto start
                bool qAutoStart = false;
                if (nvc.HasKey("autoStart"))
                {
                    bool.TryParse(nvc.Get("autoStart"), out qAutoStart);
                }

                //bg color
                string qBgColor = (nvc.HasKey("bgcolor")) ? nvc.Get("bgcolor") : "";

                //wmode
                WMode qWMode = WMode.Transparent;
                if (nvc.HasKey("wmode"))
                {
                    string wmode = nvc.Get("wmode").ToLower();
                    if (wmode.Equals(WMode.Opaque.ToString().ToLower()))
                    {
                        qWMode = WMode.Opaque;
                    }
                    if (wmode.Equals(WMode.Window.ToString().ToLower()))
                    {
                        qWMode = WMode.Window;
                    }
                }

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<html><head>");
                sb.AppendLine("</head><body>");

                string uniqueID = "video_" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.FFFF");
                switch (p.PlaylistType)
                {
                case PlayerPlaylistType.VideoList:
                    sb.AppendLine(EmbedCode.GetVideoListPlayerEmbedCode(qPlayer, qVideo, qPlaylist, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID));
                    break;

                case PlayerPlaylistType.Tabbed:
                    sb.AppendLine(EmbedCode.GetTabbedPlayerEmbedCode(qPlayer, qVideo, qPlaylistIds, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID));
                    break;

                case PlayerPlaylistType.ComboBox:
                    sb.AppendLine(EmbedCode.GetComboBoxPlayerEmbedCode(qPlayer, qVideo, qPlaylistIds, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID));
                    break;

                case PlayerPlaylistType.None:
                    sb.AppendLine(EmbedCode.GetVideoPlayerEmbedCode(qPlayer, qVideo, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID));
                    break;
                }

                sb.AppendLine("</body></html>");
                context.Response.Write(sb.ToString());
            }
            return;
        }
        // Methods
        private void DoProcessRequest(HttpContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            //return DoProcessRequest(context, request, media);
            if (context != null)
            {
                NameValueCollection source = context.Request.QueryString;
                var dict = source.Cast <string>()
                           .Select(s => new { Key = s, Value = source[s] })
                           .ToDictionary(x => x.Key, y => y.Value);

                //player
                long   qPlayer   = 0;
                string playerKey = "player";
                if (dict.ContainsKey(playerKey))
                {
                    long.TryParse(dict[playerKey], out qPlayer);
                    dict.Remove(playerKey);
                }
                PlayerItem p = PlayerLibraryItem.GetPlayer(qPlayer);
                if (p == null)
                {
                    context.Response.Write("The player is null"); return;
                }

                //video
                long   qVideo   = 0;
                string videoKey = "video";
                if (dict.ContainsKey(videoKey))
                {
                    long.TryParse(dict[videoKey], out qVideo);
                    dict.Remove(videoKey);
                }

                //playlist ids
                long        qPlaylist    = 0;
                List <long> qPlaylistIds = new List <long>();
                string      playlistKey  = "playlists";
                if (dict.ContainsKey(playlistKey))
                {
                    string[] playlistids = dict[playlistKey].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    //if you only want a single
                    if (p.PlaylistType.Equals(PlayerPlaylistType.None))
                    {
                        if (playlistids.Any())
                        {
                            long.TryParse(playlistids[0], out qPlaylist);
                        }
                    }
                    else                         //you're looking for multiple
                    {
                        foreach (string id in playlistids)
                        {
                            long plist = -1;
                            if (long.TryParse(id, out plist))
                            {
                                qPlaylistIds.Add(plist);
                            }
                        }
                    }
                    dict.Remove(playlistKey);
                }

                //remove height, width and iframe
                string heightKey = "height", widthKey = "width", iframeKey = "iframe";
                if (dict.ContainsKey(heightKey))
                {
                    dict.Remove(heightKey);
                }
                if (dict.ContainsKey(widthKey))
                {
                    dict.Remove(widthKey);
                }
                if (dict.ContainsKey(iframeKey))
                {
                    dict.Remove(iframeKey);
                }

                //auto start
                bool   qAutoStart   = false;
                string autoStartKey = "autoStart";
                if (dict.ContainsKey(autoStartKey))
                {
                    bool.TryParse(dict[autoStartKey], out qAutoStart);
                    dict.Remove(autoStartKey);
                }

                //bg color
                string bgKey    = "bgcolor";
                string qBgColor = (dict.ContainsKey(bgKey)) ? dict[bgKey] : "";
                if (!qBgColor.Contains("#"))
                {
                    qBgColor = "#" + qBgColor;
                }
                dict.Remove(bgKey);

                //converts oparams to key value pairs
                string paramKey = "oparams";
                string qParams  = string.Empty;
                if (dict.ContainsKey(paramKey))
                {
                    string[] oparams = dict[paramKey].Split(',');
                    foreach (string pair in oparams)
                    {
                        string[] kv = pair.Split('=');
                        if (kv.Length > 1)
                        {
                            dict.Add(kv[0], kv[1]);
                        }
                    }
                    dict.Remove(paramKey);
                }

                //wmode
                string wmodeKey = "wmode";
                WMode  qWMode   = (!dict.ContainsKey(wmodeKey) || string.IsNullOrEmpty(dict[wmodeKey])) ? BrightcoveSDK.WMode.Transparent : (BrightcoveSDK.WMode)Enum.Parse(typeof(BrightcoveSDK.WMode), dict[wmodeKey], true);
                dict.Remove(wmodeKey);

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("<html><head>");
                sb.AppendLine("</head><body>");

                string uniqueID = "video_" + DateTime.Now.ToString("yyyy.MM.dd.HH.mm.ss.FFFF");
                switch (p.PlaylistType)
                {
                case PlayerPlaylistType.VideoList:
                    sb.AppendLine(EmbedCode.GetVideoListPlayerEmbedCode(qPlayer, qPlaylist, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID, dict));
                    break;

                case PlayerPlaylistType.Tabbed:
                    sb.AppendLine(EmbedCode.GetTabbedPlayerEmbedCode(qPlayer, qPlaylistIds, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID, dict));
                    break;

                case PlayerPlaylistType.ComboBox:
                    sb.AppendLine(EmbedCode.GetComboBoxPlayerEmbedCode(qPlayer, qPlaylistIds, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID, dict));
                    break;

                case PlayerPlaylistType.None:
                    sb.AppendLine(EmbedCode.GetVideoPlayerEmbedCode(qPlayer, qVideo, p.Height, p.Width, qBgColor, qAutoStart, qWMode, uniqueID, dict));
                    break;
                }

                sb.AppendLine("</body></html>");
                context.Response.Write(sb.ToString());
            }
            return;
        }