MediaPlayer.OnClientCurrentStateChanged Property
Gets or sets the name of the client JavaScript function (event handler) that is called when the Sys.UI.Silverlight.MediaPlayer.currentStateChanged 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 OnClientCurrentStateChanged As String
Get
Set
'Usage
Dim instance As MediaPlayer
Dim value As String
value = instance.OnClientCurrentStateChanged
instance.OnClientCurrentStateChanged = value
[BindableAttribute(true)]
public virtual string OnClientCurrentStateChanged { get; set; }
Property Value
Type: System.String
The name of the JavaScript function that is called when the state changes.
Remarks
The currentStateChanged client event occurs at runtime when the state of the Sys.UI.Silverlight.MediaPlayer client control changes. This can occur when something happens during playback, such as when the media finishes playing, or when the user interacts with the media player, such as when the user adjusts the volume or pauses the media playback.
You can indicate the client JavaScript function to run when the currentStateChanged event occurs using the OnClientCurrentStateChanged property.
The Sys.UI.Silverlight.MediaPlayer client control can be in any one of the following states:
Closed
Opening
Buffering
Playing
Paused
Stopped
Individualizing
AcquiringLicense
The Sys.UI.Silverlight.MediaPlayer state can be nulla null reference (Nothing in Visual Basic) if the state is undetermined.
Examples
The following example demonstrates how to set the name of a JavaScript function to run when the state of the client Sys.UI.Silverlight.MediaPlayer changes at runtime and the Sys.UI.Silverlight.MediaPlayer.currentStateChanged client event occurs. This code example is part of a larger example provided for the Sys.UI.Silverlight.MediaPlayer class.
The markup shows the OnClientCurrentStateChanged property on the MediaPlayer server control indicating that currentStateChanged is the name of the JavaScript function to run when a currentStateChanged 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 currentStateChanged JavaScript function.
function currentStateChanged(sender, args) {
var state = sender.get_currentState();
var textMessage = String.format("currentStateChanged event: state '{0}'", state);
ta.innerText += '\r\n' + textMessage;
}
function currentStateChanged(sender, args) {
var state = sender.get_currentState();
var textMessage = String.format("currentStateChanged event: state '{0}'", state);
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
System.Web.UI.SilverlightControls Namespace