示例#1
0
        private string GetSource(VideoModel video)
        {
            int    ind  = video.Link.LastIndexOf('/');
            string code = video.Link.Substring(ind + 1);

            return(string.Format("//www.youtube.com/embed/{0}?rel=0", code));
        }
示例#2
0
        private void WriteVideoTitle(VideoModel video, XmlElement coldiv)
        {
            var h4 = newDoc.CreateElement("h4");

            h4.InnerText = video.Title;
            coldiv.AppendChild(h4);
        }
示例#3
0
 private void WriteSubhead(VideoModel video, XmlElement coldiv)
 {
     if (video.IsBibleHour)
     {
         var p = newDoc.CreateElement("p");
         p.InnerText = string.Format("Our Bible Hour presentation on {0:d MMMM yyyy}", video.Date);
         coldiv.AppendChild(p);
     }
 }
示例#4
0
        private void WriteDetails(VideoModel video, XmlElement coldiv)
        {
            if (!string.IsNullOrWhiteSpace(video.Details))
            {
                var p = newDoc.CreateElement("p");
                p.InnerText = video.Details;
                coldiv.AppendChild(p);
            }

            if (!string.IsNullOrWhiteSpace(video.Speaker))
            {
                var p = newDoc.CreateElement("p");
                p.InnerText = string.Format("The speaker is {0}", video.Speaker);
                if (!string.IsNullOrWhiteSpace(video.Ecclesia))
                {
                    p.InnerText += string.Format(" from the {0} ecclesia", video.Ecclesia);
                }
                coldiv.AppendChild(p);
            }
        }
示例#5
0
        private void WriteVideoIframe(VideoModel video, XmlElement coldiv)
        {
            Size size   = video.GetSize();
            var  iframe = newDoc.CreateElement("iframe");

            ///////// doesn't work! ////////// iframe.IsEmpty = false; // ensure it gets a closing tag (self-closed iframe doesn't work)
            iframe.InnerText = " ";             ///////////// try this
            AppendAttribute(iframe, "width", size.Width.ToString());
            AppendAttribute(iframe, "height", size.Height.ToString());
            AppendAttribute(iframe, "style", "border:0;");
            AppendAttribute(iframe, "allowfullscreen", null);
            if (size.Width <= 160)
            {
                AppendAttribute(iframe, "class", "video-thumbnail");
            }
            else
            {
                AppendAttribute(iframe, "class", "video640");
            }
            AppendAttribute(iframe, "src", GetSource(video));
            coldiv.AppendChild(iframe);
        }
示例#6
0
        // aiming to write something like this:

        /*
         *	<div id="apostles">
         *		<div class="col-md-4">
         *          <h4>The message of the 1st century apostles</h4>
         *          <p>Our Bible Hour presentation on 21 September 2014</p>
         *          <iframe width="640" height="360" src="//www.youtube.com/embed/rbCmozQUjRE?rel=0" frameborder="0" allowfullscreen class="video640"></iframe>
         *          <p>The speaker is Paul Newman from the Pershore ecclesia.</p>
         *      </div>
         *  </div>
         *
         * OR
         *	<div id="apostles">
         *		<div class="col-md-4">
         *          <iframe width="160" height="90" src="//www.youtube.com/embed/rbCmozQUjRE?rel=0" frameborder="0" allowfullscreen class="video-thumbnail"></iframe>
         *      </div>
         *      <div class="col-md-8">
         *          <h4>The message of the 1st century apostles</h4>
         *          <p>Our Bible Hour presentation on 21 September 2014</p>
         *          <p>The speaker is Paul Newman from the Pershore ecclesia.</p>
         *      </div>
         *  </div>
         *
         */

        private void WriteVideo(XmlNode root, VideoModel video)
        {
            XmlElement div = newDoc.CreateElement("div");

            if (!string.IsNullOrWhiteSpace(video.Tag))
            {
                AppendAttribute(div, "id", video.Tag);
                AppendAttribute(div, "class", "row");
            }

            XmlElement coldiv = newDoc.CreateElement("div");
            Size       size   = video.GetSize();

            if (size.Width > 160)
            {
                AppendAttribute(coldiv, "class", "col-md-12");
                WriteVideoTitle(video, coldiv);
                WriteSubhead(video, coldiv);
                WriteVideoIframe(video, coldiv);
                WriteDetails(video, coldiv);
                div.AppendChild(coldiv);
            }
            else
            {
                AppendAttribute(coldiv, "class", "col-md-3");
                WriteVideoIframe(video, coldiv);
                div.AppendChild(coldiv);
                coldiv = newDoc.CreateElement("div");
                AppendAttribute(coldiv, "class", "col-md-9");
                WriteVideoTitle(video, coldiv);
                WriteSubhead(video, coldiv);
                WriteDetails(video, coldiv);
                div.AppendChild(coldiv);
            }
            root.AppendChild(div);
        }