How to embed video into your source code

In this post, I will be showing how to embed publicly hosted video into your Delphi source code. I’ll be using YouTube as an example hosting provider, but in practice, Viddler is probably a better choice because of its embedded comments feature and corporate support.

 

 

What to do

    1. Locate your CodeInsight directory. Eg. “C:Program FilesEmbarcaderoRAD Studio7.0ObjReposen” .
    2. Backup your original HelpInsight.xsl file.
    3. Open this file in an editor and locate the node <xsl:template match=”summary”>
    4. After the close of this node, insert the following node
&lt;xsl:template match=&quot;youtube&quot;&gt;
	&lt;iframe width=&quot;560&quot; height=&quot;315&quot; frameborder=&quot;0&quot; controls=&quot;0&quot;&gt;
	  &lt;xsl:attribute name=&quot;src&quot;&gt;http://www.youtube.com/embed/&lt;xsl:value-of select=&quot;@id&quot;/&gt;&lt;/xsl:attribute&gt;
	&lt;/iframe&gt;
&lt;/xsl:template&gt;
  1. Locate the <xsl:apply-templates select=”member/summary”/> node. Just after that one insert:
    &lt;xsl:apply-templates select=&quot;member/youtube&quot;&gt;
  2. Save and close HelpInsight.xsl file.
  3. Open up Delphi. Just before the class or declarative element that you which to annotate, insert something like this …
    {$REGION 'xmldoc'}
    type
    ///  &lt;summary&gt;Play this video!&lt;/summary&gt;
    ///  &lt;youtube id=&quot;PWNLPl7oIRc&quot;/&gt;
    {$ENDREGION}

    Replace the id code with the YouTube id of your annotating video. The Summary node is completely optional. The “Type” inside the folded region is important – I’ll explain that in a moment.

  4. Close the folded region.
  5. Mouse over your target class or declarative element. Give it a second, and Alakhazam! Embedded Video!

So what’s with the extraneous “type” inside the folded region?

Delphi’s Help Insight feature has a surprising anomaly (read “bug”). If you have two or more type declarations in a unit, Help Insight only works on the first declarative element after the “type” keyword. Where normally, a developer would tend to write:

type
 TMyFirstType = banana banana banana;
 TMySecondType = banana banana banana;

To get Help Insight to work on both declarations, we have to write it like this:

type
{$REGION 'xmldoc'}
/// &lt;summary&gt;This is about TMyFirstType. It involves a lot of bananas.&lt;/summary&gt;
{$ENDREGION}
 TMyFirstType = banana banana banana;
{$REGION 'xmldoc'}
type
/// &lt;summary&gt;This is about TSecondFirstType.&lt;/summary&gt;
{$ENDREGION}
 TMySecondType = banana banana banana;

Embed
The funny thing is, that if you choose Viddler over YouTube and you embed some comments in your video, what is presented to the client-developer is text comments embedded in video embedded in XML embedded in source code.

Posted in IDE
3 comments on “How to embed video into your source code
  1. Awesome! I’m gonna try it now!

  2. LachlanG says:

    This is amazingly cool and incredibly useless 🙂

    I can get it to work with XE but in XE2 due to the bundled Documentation Insight plugin the HelpInsight.xsl file has a completely different structure and doesn’t seem to have the corresponding sections.

  3. Christopher says:

    Hello just wanted to give you a quick heads up.

    The text in your article seem to be running off the screen in Internet explorer.
    I’m not sure if this is a formatting issue or something to do with browser compatibility but I thought I’d post to let
    you know. The design look great though! Hope you get the issue
    resolved soon. Kudos

2 Pings/Trackbacks for "How to embed video into your source code"
  1. […] to embed video into your source code See my entry here on the ADUG shared blog. Posted by Sean B. Durkin at 15:40 | Comments (0) | Trackbacks (0) […]

  2. […] Bild als Kommentar   Heute, 10:56 So einem Beitrag gab es auch mal. Es wird gleich ein ganzes Video quasi in den Quelltext eingebaut. Achtung: Bin […]