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;;xsl:value-of select=&quot;@id&quot;/&gt;&lt;/xsl:attribute&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'}
    ///  &lt;summary&gt;Play this video!&lt;/summary&gt;
    ///  &lt;youtube id=&quot;PWNLPl7oIRc&quot;/&gt;

    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:

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

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

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

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.

5 Responses

  1. 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.

  2. 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