Share via


Video.Silverlight Method

Plays a video using the Silverlight player.

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

Syntax

'Declaration
Public Shared Function Silverlight ( _
    path As String, _
    width As String, _
    height As String, _
    bgColor As String, _
    initParameters As String, _
    minimumVersion As String, _
    autoUpgrade As Boolean, _
    options As Object, _
    htmlAttributes As Object _
) As HelperResult
'Usage
Dim path As String
Dim width As String
Dim height As String
Dim bgColor As String
Dim initParameters As String
Dim minimumVersion As String
Dim autoUpgrade As Boolean
Dim options As Object
Dim htmlAttributes As Object
Dim returnValue As HelperResult

returnValue = Video.Silverlight(path, _
    width, height, bgColor, initParameters, _
    minimumVersion, autoUpgrade, options, _
    htmlAttributes)
public static HelperResult Silverlight(
    string path,
    string width,
    string height,
    string bgColor,
    string initParameters,
    string minimumVersion,
    bool autoUpgrade,
    Object options,
    Object htmlAttributes
)
public:
static HelperResult^ Silverlight(
    String^ path, 
    String^ width, 
    String^ height, 
    String^ bgColor, 
    String^ initParameters, 
    String^ minimumVersion, 
    bool autoUpgrade, 
    Object^ options, 
    Object^ htmlAttributes
)
public static function Silverlight(
    path : String, 
    width : String, 
    height : String, 
    bgColor : String, 
    initParameters : String, 
    minimumVersion : String, 
    autoUpgrade : boolean, 
    options : Object, 
    htmlAttributes : Object
) : HelperResult

Parameters

  • path
    Type: System.String
    The URL that provides the path to a media file to play.
  • width
    Type: System.String
    The width of the player in either pixels or as a percentage of the browser window.
  • bgColor
    Type: System.String
    (Optional) The background color of the Silverlight player.
  • initParameters
    Type: System.String
    (Optional) A comma-delimited array that contains named values to pass to the Silverlight .xap file.
  • minimumVersion
    Type: System.String
    (Optional) The minimum Silverlight plug-in host version that is required in order to play the specified media file.
  • autoUpgrade
    Type: System.Boolean
    (Optional) A value that indicates whether the Silverlight plug-in should automatically be upgraded.
  • options
    Type: System.Object
    (Optional) A comma-delimited array that contains named values to pass to the Silverlight 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.

Return Value

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

Remarks

The Silverlight player of the Video class enables several file types to be played in a web page, including Windows Media videos (.wmv files), Windows Media audio (.wma files), MPEG-4 (.mp4), and MP3 (.mp3 files). The path parameter must be set to point to a Silverlight-based application package (.xap file). The width and height parameters must also be set. All other parameters are optional. If only the required parameters are set, the Silverlight player displays the video without a background color.

A Silverlight .xap file is a compressed file that contains layout instructions in a .xaml file, managed code in assemblies, and optional resources. A .xap file can be created in Visual Studio as a Silverlight application project. The initParameters parameter can be used to pass values from a Web page to the .xap file. The values in the initParameters parameter can be used to initialize your Silverlight application.

Examples

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

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Silverlight Video</title> 
    </head> 
    <body> 
        @Video.Silverlight( 
            path: "Media/sample.xap",  
            width: "400",  
            height: "600",  
            bgColor: "black",  
            autoUpgrade: true) 
    </body> 
</html>

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