简体   繁体   中英

Silverlight play,pause and resume events

I am using silverlight player in our project. It is working well. These days I was loking for silverlight events becasue I will send some information to google analytics on player pause,resume and play events. I checked lots of article. Unfortunately there is no information about these events. All articles give the same example and same events.(onError and onLoad events). How can I add play,pause and resume events in javascript? Please check below javascript code.

          Silverlight.createObject("XXXXXXXXX",player.get(0),"xxPlayer",
                                  {
                                    width: playerWidth + "", height: playerHeight + "", background: "black"version: "4.0.60310.0",enableHtmlAccess: true'},
                                                       { onError: onSilverlightError, onLoad: null },
                                                       extra, "context");

There is a general purpose CurrentStateChanged event which returns the current state of the media (playing, stopped, etc.)

MediaElement events

To access the events you need something like this:

player = sender.findName("ObjectName");
var stateChangedToken = player.addEventListener("CurrentStateChanged", onCurrentStateChanged);

Then you can fill out the onCurrentStateChanged JavaScript to do what you want.

Handling Silverlight events in JavaScript (MSDN)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM