コード例 #1
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);
        }
コード例 #2
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);
        }