How to get “Seconds Played” and “Percentage Played

2019-05-25 07:56发布

问题:

I see the new JW Player 6 Enterprise has lost the capability to report Seconds Played and Percentage Played as Google Analytics Events.

Has anyone developed a method to produce something like this? I imagine the JW Player API and some JavaScript could support these events.

[We made great use of the Seconds Played and Percentage Played capabilities in JW Player 5, and I'm sad to see it go. If anyone from JWPlayer is listening: it would be great to have those events back!]

回答1:

I think you could recreate the seconds played tracking on your own with the onTime callback. Try this:

var currentDuration = -1;
var currentPosition = -1;
var jw = jwplayer();
jw.onTime(function() {
    var position = this.getPosition();
    var duration = this.getDuration();
    if ((duration === currentDuration && position === currentPostion) || duration === -1 ) {
      return;
    }
    currentPosition = position;
    currentDuration = duration;
    var file = this.getPlaylistItem().file
    return _gaq.push(['_trackEvent', 'JW Player Seconds Played', file, window.location.href);
});