Share via


MediaPlayer.OnClientChapterSelected Property

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

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

Syntax

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

value = instance.OnClientChapterSelected

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

Property Value

Type: System.String
The name of the JavaScript function that is called when a chapter is selected.

Remarks

The chapterSelected client event occurs at runtime when a user clicks a NextButton or PreviousButton element of a Sys.UI.Silverlight.MediaPlayer skin to jump to the next chapter or previous chapter during media playback or when a user selects a chapter by clicking a thumbnail representation of that chapter to set the media playback position to the start of that chapter.

You can indicate the client JavaScript function to run when the chapterSelected client event occurs using the OnClientChapterSelected property.

After the chapterSelected client event occurs and playback begins, the Sys.UI.Silverlight.MediaPlayer.chapterStarted client event occurs.

Examples

The following example demonstrates how to set the name of a JavaScript function to run when a chapter is selected during playback and the chapterSelected client event occurs. This code example is part of a larger example provided for the Sys.UI.Silverlight.MediaPlayer class.

The markup shows the OnClientChapterSelected property on the MediaPlayer server control indicating that chapterSelected is the name of the JavaScript function to run when a chapterStarted 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 chapterSelected JavaScript function.

function chapterSelected(sender, args) {
    var chapter = args.get_chapter();
    if (chapter)
    {
        var title = chapter.get_title();
        var textMessage = String.format("chapterSelected event: title '{0}'", title);
        ta.innerText +=  '\r\n' + textMessage;
    } 
} 
function chapterSelected(sender, args) {
    var chapter = args.get_chapter();
    if (chapter)
    {
        var title = chapter.get_title();
        var textMessage = String.format("chapterSelected event: title '{0}'", title);
        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

Other Resources

XAML Elements of the MediaPlayer Skin

Walkthrough: Creating Chapter Markers for the MediaPlayer Control