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 Files\Embarcadero\RAD Studio\7.0\ObjRepos\en” .
    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
<xsl:template match="youtube">
	<iframe width="560" height="315" frameborder="0" controls="0">
	  <xsl:attribute name="src"><xsl:value-of select="@id"/></xsl:attribute>
  1. Locate the <xsl:apply-templates select=”member/summary”/> node. Just after that one insert:
    <xsl:apply-templates select="member/youtube">
  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'}
    ///  <summary>Play this video!</summary>
    ///  <youtube id="PWNLPl7oIRc"/>

    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'}
/// <summary>This is about TMyFirstType. It involves a lot of bananas.</summary>
 TMyFirstType = banana banana banana;
{$REGION 'xmldoc'}
/// <summary>This is about TSecondFirstType.</summary>
 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 thoughts on “How to embed video into your source code

  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. Pingback: How to embed video into your source code - Pascaliburnus

  3. Pingback: Bild als Kommentar - Delphi-PRAXiS

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

Comments are closed.