Share via


MediaPlayer.OnClientMarkerReached Property

Gets or sets the name of the client JavaScript function (event handler) that is called when the Sys.UI.Silverlight.MediaPlayer.markerReached event occurs.

Namespace:  System.Web.UI.SilverlightControls
Assembly:  System.Web.Silverlight (in System.Web.Silverlight.dll)

Syntax

'Declaration
<BindableAttribute(True)> _
Public Overridable Property OnClientMarkerReached As String
    Get
    Set
'Usage
Dim instance As MediaPlayer
Dim value As String

value = instance.OnClientMarkerReached

instance.OnClientMarkerReached = value
[BindableAttribute(true)]
public virtual string OnClientMarkerReached { get; set; }

Property Value

Type: System.String
The name of the JavaScript function that is called when the player reaches a marker.

Remarks

The markerReached client event occurs at runtime when a marker is reached during playback of the media file.

A marker is a position in a media file that has associated metadata. Markers are embedded in a media file when that file is encoded using a product such as Microsoft Expression Encoder.

You can indicate the client JavaScript function to run when a markerReached event occurs using the OnClientMarkerReached property.

Captions encoded in a media file are detected as markers during playback.

For more information about markers and captions, see ASP.NET MediaPlayer Server Control.

Examples

The following example demonstrates how to set the name of a JavaScript function to run when a marker in the media file is reached during playback at runtime and the Sys.UI.Silverlight.MediaPlayer.markerReached client event occurs. This code example is part of a larger example provided for the Sys.UI.Silverlight.MediaPlayer class.

The markup shows the OnClientMarkerReached property on MediaPlayer server control indicating that markerReached is the name of the JavaScript function to run when a Sys.UI.Silverlight.MediaPlayer.markerReached client event occurs at runtime.

<asp:MediaPlayer ID="MediaPlayer1" runat="server" Height="300px" Width="400px" 
    OnClientChapterSelected="chapterSelected" 
    OnClientChapterStarted="chapterStarted" 
    OnClientCurrentStateChanged="currentStateChanged" 
    OnClientMarkerReached="markerReached" 
    OnClientMediaEnded="mediaEnded" 
    OnClientMediaFailed="mediaFailed" 
    OnClientMediaOpened="mediaOpened" 
    OnClientVolumeChanged="volumeChanged"
    onPluginFullScreenChanged="fullScreenChanged"
    MediaSource="../media/expressionstudio.wmv" AutoPlay="True" 
    MediaSkinSource="../skins/Professional.xaml">
    <Chapters>
        <asp:MediaChapter Position="5" Title="A New Start" ThumbnailSource="../images/Water lilies.jpg" />
        <asp:MediaChapter Position="22" Title="More Things" ThumbnailSource="../images/Sunset.jpg"/>
        <asp:MediaChapter Position="54" Title="Final Thoughts" ThumbnailSource="../images/Blue hills.jpg" />
    </Chapters>
</asp:MediaPlayer>
<asp:MediaPlayer ID="MediaPlayer1" runat="server" Height="300px" Width="400px" 
    OnClientChapterSelected="chapterSelected" 
    OnClientChapterStarted="chapterStarted" 
    OnClientCurrentStateChanged="currentStateChanged" 
    OnClientMarkerReached="markerReached" 
    OnClientMediaEnded="mediaEnded" 
    OnClientMediaFailed="mediaFailed" 
    OnClientMediaOpened="mediaOpened" 
    OnClientVolumeChanged="volumeChanged"
    onPluginFullScreenChanged="fullScreenChanged"
    MediaSource="../media/expressionstudio.wmv" AutoPlay="True" 
    MediaSkinSource="../skins/Professional.xaml">
    <Chapters>
        <asp:MediaChapter Position="5" Title="A New Start" ThumbnailSource="../images/Water lilies.jpg" />
        <asp:MediaChapter Position="22" Title="More Things" ThumbnailSource="../images/Sunset.jpg"/>
        <asp:MediaChapter Position="54" Title="Final Thoughts" ThumbnailSource="../images/Blue hills.jpg" />
    </Chapters>
</asp:MediaPlayer>

The client script shows the markerReached JavaScript function.

function markerReached(sender, args) {
    var marker = args.get_marker();
    try {
        var markerText = marker.type;
    }
    catch(e) {
        var markerText = "unknown marker type";
    }

    var currentPosition = sender.get_position();
    var textMessage = String.format("markerReached event: '{0}' at {1} seconds", markerText, currentPosition);
    ta.innerText +=  '\r\n' + textMessage;
}        
function markerReached(sender, args) {
    var marker = args.get_marker();
    try {
        var markerText = marker.type;
    }
    catch(e) {
        var markerText = "unknown marker type";
    }

    var currentPosition = sender.get_position();
    var textMessage = String.format("markerReached event: '{0}' at {1} seconds", markerText, currentPosition);
    ta.innerText +=  '\r\n' + textMessage;
}        

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

MediaPlayer Class

MediaPlayer Members

System.Web.UI.SilverlightControls Namespace

EnableCaptions