Video.MediaPlayer Method

Plays a media file (.wmv video or audio file) using the Windows MediaPlayer player.

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

Syntax

'Declaration
Public Shared Function MediaPlayer ( _
    path As String, _
    width As String, _
    height As String, _
    autoStart As Boolean, _
    playCount As Integer, _
    uiMode As String, _
    stretchToFit As Boolean, _
    enableContextMenu As Boolean, _
    mute As Boolean, _
    volume As Integer, _
    baseUrl 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 autoStart As Boolean
Dim playCount As Integer
Dim uiMode As String
Dim stretchToFit As Boolean
Dim enableContextMenu As Boolean
Dim mute As Boolean
Dim volume As Integer
Dim baseUrl As String
Dim options As Object
Dim htmlAttributes As Object
Dim embedName As String
Dim returnValue As HelperResult

returnValue = Video.MediaPlayer(path, _
    width, height, autoStart, playCount, _
    uiMode, stretchToFit, enableContextMenu, _
    mute, volume, baseUrl, options, htmlAttributes, _
    embedName)
public static HelperResult MediaPlayer(
    string path,
    string width,
    string height,
    bool autoStart,
    int playCount,
    string uiMode,
    bool stretchToFit,
    bool enableContextMenu,
    bool mute,
    int volume,
    string baseUrl,
    Object options,
    Object htmlAttributes,
    string embedName
)
public:
static HelperResult^ MediaPlayer(
    String^ path, 
    String^ width, 
    String^ height, 
    bool autoStart, 
    int playCount, 
    String^ uiMode, 
    bool stretchToFit, 
    bool enableContextMenu, 
    bool mute, 
    int volume, 
    String^ baseUrl, 
    Object^ options, 
    Object^ htmlAttributes, 
    String^ embedName
)
public static function MediaPlayer(
    path : String, 
    width : String, 
    height : String, 
    autoStart : boolean, 
    playCount : int, 
    uiMode : String, 
    stretchToFit : boolean, 
    enableContextMenu : boolean, 
    mute : boolean, 
    volume : int, 
    baseUrl : String, 
    options : Object, 
    htmlAttributes : Object, 
    embedName : String
) : HelperResult

Parameters

  • path
    Type: System.String
    The URL that provides the path to the media file to play.
  • width
    Type: System.String
    (Optional) The width of the player in either pixels or as a percentage of the browser window.
  • autoStart
    Type: System.Boolean
    (Optional) true to play the media file after the Web page finishes rendering; otherwise, false. The default is true.
  • playCount
    Type: System.Int32
    (Optional) The number of times to repeat the media file. The default is 1.
  • uiMode
    Type: System.String
    A value that determines which controls are displayed in the player UI.
  • stretchToFit
    Type: System.Boolean
    (Optional) true to maintain the original aspect ratio of a video; otherwise, false. The default is false.
  • enableContextMenu
    Type: System.Boolean
    (Optional) true to provide a right-click menu; otherwise, false. The default is true.
  • mute
    Type: System.Boolean
    (Optional) true to play a video without audio; otherwise, false. The default is false.
  • volume
    Type: System.Int32
    (Optional) A number (0 to 100) that controls the audio level of the player.
  • baseUrl
    Type: System.String
    (Optional) The base URL that is used to resolve relative paths to a media source.
  • options
    Type: System.Object
    (Optional) A comma-delimited array that contains values to pass to the MediaPlayer 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 rendered when the HTML object is rendered that contains the video HTML reference.

Return Value

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

Remarks

The MediaPlayer 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). You must include the path parameter that specifies the media file to play; all other parameters are optional. If you specify only a path, the player uses default settings that are set by the current version of MediaPlayer, such as the following:

  • Videos are played using their default width and height.

  • Media files play automatically when the page loads.

  • Media files play once (they do not loop).

  • The player displays the full set of controls in the user interface.

  • The media file plays in in a separate window.

The MediaPlayer player provides the uiMode parameter to specify which controls are displayed in the user interface. If the uiMode parameter is not specified, the player is displayed with a status window, seek bar, control buttons, and volume controls.

Examples

The following example shows how to use the MediaPlayer method to play videos.

<!DOCTYPE html> 
<html> 
    <head> 
        <title>MediaPlayer Video</title> 
    </head> 
    <body> 
        @Video.MediaPlayer( 
            path: "Media/sample.wmv",  
            width: "400",  
            height: "600",  
            autoStart: true,  
            playCount: 2,  
            uiMode:  "full", 
            stretchToFit: true, 
            enableContextMenu: true, 
            mute: false, 
            volume: 75)
    </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