Esempio n. 1
0
        public override string CreateRenderedViewerMarkup(Uri url, int maxWidth, int maxHeight)
        {
            string videoUrl = new BcWebClient().ResolveMinifiedUrl(url);

            //WORKAROUND for telligent bug
            videoUrl = videoUrl.Replace("&", "&");

            Match match = BcRegex.Match(videoUrl);

            if (match.Success)
            {
                int height = 450;
                int width  = 480;

                bool   isHttps   = !string.IsNullOrEmpty(match.Groups["https"].Value);
                string playerId  = match.Groups["playerId"].Value;
                string playerKey = match.Groups["playerKey"].Value;
                string videoId   = match.Groups["videoId"].Value;

                Globals.ScaleUpDown(ref width, ref height, maxWidth, maxHeight);

                string playerHtml = string.Format(PlayerHtmlTemplateBody, playerId, videoId, playerKey, width, height, isHttps?PLayerHtmlHttpsModifier:string.Empty);

                CSContext context = CSContext.Current;
                Page      page    = null;
                if (context.Context != null)
                {
                    page = context.Context.Handler as Page;
                }

                if (page != null)
                {
                    string id = "video_" + Guid.NewGuid();

                    var wrapper = new StringBuilder();

                    wrapper.Append("<script type=\"text/javascript\" src=\"");
                    wrapper.Append(
                        Globals.FullPath(page.ClientScript.GetWebResourceUrl(typeof(BrightcoveMediaViewer),
                                                                             "FourRoads.Common.TelligentCommunity.Plugins.insertmarkup.js")));
                    wrapper.Append("\"></script>");

                    wrapper.AppendFormat("<div id=\"{0}\"><noscript>{1}</noscript></div>", id, playerHtml);
                    wrapper.Append(string.Format(PlayerHtmlTemplateHead, isHttps ? "s":string.Empty));
                    wrapper.Append("<script type=\"text/javascript\">\n");
                    wrapper.Append("cs_setInnerHtml('");
                    wrapper.Append(id);
                    wrapper.Append("','");
                    wrapper.Append(JavaScript.Encode(playerHtml));
                    wrapper.Append("');");
                    wrapper.Append("\n</script>");
                    wrapper.Append(PlayerHtmlTemplateTail);

                    return(wrapper.ToString());
                }
                return(playerHtml);
            }
            return(string.Empty);
        }
    public override string CreateRenderedViewerMarkup(Uri url, int maxWidth, int maxHeight)
    {
      string videoUrl = new BcWebClient().ResolveMinifiedUrl(url);

      //WORKAROUND for telligent bug
      videoUrl = videoUrl.Replace("&amp;", "&");

      Match match = BcRegex.Match(videoUrl);

      if (match.Success)
      {
        int height = 450;
        int width = 480;

        bool isHttps = !string.IsNullOrEmpty(match.Groups["https"].Value);
        string playerId = match.Groups["playerId"].Value;
        string playerKey = match.Groups["playerKey"].Value;
        string videoId = match.Groups["videoId"].Value;

        Globals.ScaleUpDown(ref width, ref height, maxWidth, maxHeight);

        string playerHtml = string.Format(PlayerHtmlTemplateBody, playerId, videoId, playerKey, width, height, isHttps?PLayerHtmlHttpsModifier:string.Empty);

        CSContext context = CSContext.Current;
        Page page = null;
        if (context.Context != null)
          page = context.Context.Handler as Page;

        if (page != null)
        {
          string id = "video_" + Guid.NewGuid();

          var wrapper = new StringBuilder();

          wrapper.Append("<script type=\"text/javascript\" src=\"");
          wrapper.Append(
              Globals.FullPath(page.ClientScript.GetWebResourceUrl(typeof(BrightcoveMediaViewer),
                  "FourRoads.Common.TelligentCommunity.Plugins.insertmarkup.js")));
          wrapper.Append("\"></script>");

          wrapper.AppendFormat("<div id=\"{0}\"><noscript>{1}</noscript></div>", id, playerHtml);
          wrapper.Append(string.Format(PlayerHtmlTemplateHead, isHttps ? "s":string.Empty));
          wrapper.Append("<script type=\"text/javascript\">\n");
          wrapper.Append("cs_setInnerHtml('");
          wrapper.Append(id);
          wrapper.Append("','");
          wrapper.Append(JavaScript.Encode(playerHtml));
          wrapper.Append("');");
          wrapper.Append("\n</script>");
          wrapper.Append(PlayerHtmlTemplateTail);

          return wrapper.ToString();
        }
        return playerHtml;
      }
      return string.Empty;
    }