Share via


Video.Flash Method

Plays a video (.swf file) using the Adobe Flash player.

Namespace:  Microsoft.Web.Helpers
Assembly:  Microsoft.Web.Helpers (in Microsoft.Web.Helpers.dll)

Syntax

'Declaration
Public Shared Function Flash ( _
    path As String, _
    width As String, _
    height As String, _
    play As Boolean, _
    loop As Boolean, _
    menu As Boolean, _
    bgColor As String, _
    quality As String, _
    scale As String, _
    windowMode As String, _
    baseUrl As String, _
    version As String, _
    options As Object, _
    htmlAttributes As Object, _
    embedName As String _
) As HelperResult
'Usage
Dim path As String
Dim width As String
Dim height As String
Dim play As Boolean
Dim loop As Boolean
Dim menu As Boolean
Dim bgColor As String
Dim quality As String
Dim scale As String
Dim windowMode As String
Dim baseUrl As String
Dim version As String
Dim options As Object
Dim htmlAttributes As Object
Dim embedName As String
Dim returnValue As HelperResult

returnValue = Video.Flash(path, width, _
    height, play, loop, menu, bgColor, _
    quality, scale, windowMode, baseUrl, _
    version, options, htmlAttributes, _
    embedName)
public static HelperResult Flash(
    string path,
    string width,
    string height,
    bool play,
    bool loop,
    bool menu,
    string bgColor,
    string quality,
    string scale,
    string windowMode,
    string baseUrl,
    string version,
    Object options,
    Object htmlAttributes,
    string embedName
)
public:
static HelperResult^ Flash(
    String^ path, 
    String^ width, 
    String^ height, 
    bool play, 
    bool loop, 
    bool menu, 
    String^ bgColor, 
    String^ quality, 
    String^ scale, 
    String^ windowMode, 
    String^ baseUrl, 
    String^ version, 
    Object^ options, 
    Object^ htmlAttributes, 
    String^ embedName
)
public static function Flash(
    path : String, 
    width : String, 
    height : String, 
    play : boolean, 
    loop : boolean, 
    menu : boolean, 
    bgColor : String, 
    quality : String, 
    scale : String, 
    windowMode : String, 
    baseUrl : String, 
    version : String, 
    options : Object, 
    htmlAttributes : Object, 
    embedName : String
) : HelperResult

Parameters

  • path
    Type: System.String
    The URL that provides the path to a video to play.
  • width
    Type: System.String
    (Optional) The width of the player in either pixels or as a percentage of the browser window.
  • height
    Type: System.String
    (Optional) The height of the player window.
  • play
    Type: System.Boolean
    (Optional) true to play the media file after it has been loaded; otherwise, false. The default is true.
  • loop
    Type: System.Boolean
    (Optional) true to continuously repeat the video; otherwise, false. The default is true.
  • menu
    Type: System.Boolean
    (Optional) true to display a right-click menu that has extended control options; false to display a right-click menu that provides setting options and "about" details. The default is true.
  • bgColor
    Type: System.String
    (Optional) The background color of the video represented as a hexadecimal RGB value.
  • quality
    Type: System.String
    (Optional) The quality of the video. Values can be low, autolow, autohigh, medium, high, or best.
  • scale
    Type: System.String
    (Optional) The scale of the video. Values can be showall, noorder or exactfit.
  • windowMode
    Type: System.String
    (Optional) The mode in which the video will be player. Values can be window, opaque or transparent.
  • baseUrl
    Type: System.String
    (Optional) The base URL that is used to resolve relative paths to a Flash media source.
  • options
    Type: System.Object
    (Optional) A comma-delimited array that contains values to pass to the Flash HTML object.
  • htmlAttributes
    Type: System.Object
    (Optional) A comma-delimited array that contains attribute names whose values are rendered as subelements of the object element in the Web page.
  • embedName
    Type: System.String
    (Optional) A name for the embed element that is used when the HTML object is rendered that contains the video HTML reference.

Return Value

Type: System.Web.WebPages.HelperResult
An object element that is represented in the rendered HTML as <object></object>.

Remarks

The Flash player that is rendered by the Video class lets you play Flash videos (.swf files) in a Web page. At a minimum, you have to provide a path to the video file. If you specify nothing but the path, the player uses default values that are set by the current version of Flash. Typical default settings are:

  • The video is played using its default width and height and without a background color.

  • The video plays automatically when the page loads.

  • The video loops continuously until it is explicitly stopped.

  • The video is scaled to show all of the video, rather than cropping the video to fit a specific size.

  • The video plays in a separate window.

The Flash player supports a video mode setting named windowMode. You can set this to window, opaque, or transparent. By default, the windowMode is set to window, which plays the video in a separate window on the web page. The opaque setting hides everything in the Web page that is behind the video. The transparent setting lets the Web page show through the video, assuming any part of the video is transparent.

You can change the Flash video to play at a specific size using the scale parameter, which you can set to the following values:

  • showall. This makes the entire video visible while maintaining the original aspect ratio. However, the player might display borders on each side of the video content.

  • noorder. This scales the video while maintaining the original aspect ratio, but the video content might be cropped.

  • exactfit. This makes the entire video visible without preserving the original aspect ratio, but the video content might appear distorted.

Examples

The following example shows how to use the Flash method to play video.

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Flash Video</title> 
    </head> 
    <body> 
        @Video.Flash(path: "Media/sample.swf",  
             width: "400",  
             height: "600",  
             play: true)
    </body> 
</html>

The following example shows how to use the scale parameter when you play a Flash video. The example does not include a scale parameter, so the entire video will be visible and the original aspect ratio will be maintained without any cropping.

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Flash Video</title> 
    </head> 
    <body> 
        @Video.Flash(path: "Media/sample.swf",  
            width: "1000",  
            height: "100",
            scale: "exactfit")

    </body> 
</html>

The following example shows how to use the options parameter, the htmlAttributes parameter, and the embedName parameter when you play a Flash video. In this example, rather than playing a Flash video, the resulting output is HTML that contains the object element that is used to play the video.

@{
    HelperResult myVideoObject = Video.Flash(path: "Media/sample.swf",  
        width: "400",  
        height: "600",  
        play: true,  
        loop: true,  
        menu:  true,  
        bgColor: "red", 
        quality: "medium", 
        scale: "exactfit", 
        windowMode: "transparent",
        options: new { idOption = "IdOptionValue", myOption = "MyOptionValue"},
        htmlAttributes: new { idAttrib = "IdAttribValue", myAttrib = "MyAttribValue"},
        embedName: "myEmbedName");
}
<!DOCTYPE html> 
<html> 
    <head> 
        <title>Flash Video</title> 
    </head> 
    <body> 
        @myVideoObject.ToString()
    </body> 
</html>

The following HTML markup shows object element that is rendered in the browser and that plays the video. This markup is generated when the code in the previous example runs on the server.

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" height="600" idAttrib="IdAttribValue" myAttrib="MyAttribValue" type="application/x-oleobject" width="400">
  <param name="movie" value="/Media/sample.swf" /> 
  <param name="idOption" value="IdOptionValue" /> 
  <param name="myOption" value="MyOptionValue" /> 
  <param name="bgColor" value="red" /> 
  <param name="quality" value="medium" /> 
  <param name="scale" value="exactfit" /> 
  <param name="wmode" value="transparent" /> 
  <embed src="/Media/sample.swf" width="400" height="600" name="myEmbedName" type="application/x-shockwave-flash" idOption="IdOptionValue" myOption="MyOptionValue" bgColor="red" quality="medium" scale="exactfit" wmode="transparent" /> 
</object>

Permissions

  • Medium trust for the immediate caller. This member can be used by partially trusted code.

See Also

Reference

Video Class

Microsoft.Web.Helpers Namespace