How to add an eventListener to get event data from JWPlayer
-
19-09-2019 - |
Question
I don't understanding what code is needed to simply output any interaction with the Flash JW Player. Below is a code demo from their documentation (results in addControllerListener being undefined). Some more details in the JW Player Flash API.
function muteTracker(obj) { alert('the new mute state is: '+obj.state); };
player.addControllerListener("MUTE","muteTracker");
I want to extend this to include functions to track all other interactions such as play, seek, fullscreen etc.
Solution
You were on the right track! If you check out the player API, you'll notice that there are three methods for adding listeners:
- player.addControllerListener(EVENT,myFunction);
- player.addModelListener(EVENT,myFunction);
- player.addViewListener(EVENT,myFunction);
Pair that with the events list (http://developer.longtailvideo.com/trac/wiki/Player4Events) and you're good to go. Thus, if you're looking to listen for seek events, it would look something like:
player.addViewListener(ViewEvent.PLAY,myFunction);
or for seek,
player.addViewListener(ViewEvent.SEEK,myFunction);
Best,
Zach
Developer, LongTail Video