GdnSwfObject Server Control

An ASP.NET server control that uses SWFObject to render Flash movies using either dynamic or static publishing methods, as well as templates for alternate content. Express installation and JavaScript library are embedded with the assembly.

QuickStart Samples

Example #1: Add an SwfObject control to a Page using markup.

<gdn:SwfObject       
  ID="swfObj1"
  AllowScriptAccess="Always" 
  BaseUrl="~/App_Support/Flash/"
  runat="server"
  MovieUrl="~/App_Support/Flash/player.swf" 
  Height="200px" 
  Width="328px"    
  UseDynamicPublishing="false"
  UseExpressInstallation="true">    
  <FlashVars>
    <gdn:FlashVar Name="file" Value="video.flv"/>
    <gdn:FlashVar Name="image" Value="preview.jpg"/>        
  </FlashVars>
  <AlternateContentTemplate>
    <p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>        
  </AlternateContentTemplate>
</gdn:SwfObject>

Example #2: Add an SwfObject control to a Page using managed code.

SwfObject                 swfObj1        = null;
SwfObjectAlternateContent swfObjContent1 = null;    
             
/* Create SwfObject control */
swfObj1                          = new SwfObject();
swfObj1.ID                       = "swfObj1";
swfObj1.AllowScriptAccess        = SwfScriptAccess.Always;
swfObj1.BaseUrl                  = "~/App_Support/Flash/";
swfObj1.MovieUrl                 = "~/App_Support/Flash/player.swf";
swfObj1.Height                   = Unit.Parse("200px");
swfObj1.Width                    = Unit.Parse("328px");        
swfObj1.UseDynamicPublishing     = false;
swfObj1.UseExpressInstallation   = true;
             
/* Add FlashVars */
swfObj1.FlashVars.Add(new FlashVar("file", "video.flv"));
swfObj1.FlashVars.Add(new FlashVar { Name = "image", Value = "preview.jpg" });
             
/* Create Alternate Content Template */
swfObjContent1                   = new SwfObjectAlternateContent();
swfObjContent1.Controls.Add(
  new LiteralControl("<p><a href=\"http://get.adobe.com/flashplayer\">Get Flash</a> to see this player.</p>"));
swfObj1.AlternateContentTemplate = swfObjContent1;
             
/* Add the SwfObject to a PlaceHolder on the Page */
this.plchGdnSwfObject.Controls.Add(swfObj1);

The above examples use JW FLV Media Player 4.4 to use an SWF to stream an FLV.

Additional Resources

Last edited Jul 14, 2009 at 8:27 PM by GrannetDotNet, version 24