Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

How to find out framerate of JW Player video on client computer


We need to display the framerate of a video that user is watching with JW Player. We have already tried tried everything with JW Player 7 API but it doesn't give us the client side frame rate.

We have built a JW Player plugin which is supposed to calculate the framerate on every ENTER_FRAME event while the video is playing.

We are listening to ENTER_FRAME event on line 61. api.addEventListener(Event.ENTER_FRAME, calculateFPS);

Everytime a new frame is entered the plugin executes calculateFPS function. The framerate is displayed in a textbox.

For some reason the calculated framerate is around 30 fps. This cannot be possible because the original framerate of the video is 15 fps. I think that the problem might be on line 61 where the eventlistener is listening to the player instead of the video. Is it possible to link the eventlistener straight to the video?

Here is the whole plugin actionscript code. It is based on a JW Player plugin example APITester.as.

package {
import com.longtailvideo.jwplayer.events.*;
import com.longtailvideo.jwplayer.player.*;
import com.longtailvideo.jwplayer.plugins.*;

import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.events.Event;

import flash.utils.getTimer;

/** An example plugin that tests various player integrations. **/
public class APITester extends Sprite implements IPlugin6 {

[Embed(source="mute.png")]
private const MuteIcon:Class;

private var api:IPlayer;
private var field:TextField;

private var clickButton:Sprite;

public var startTime:Number;
public var framesNumber:Number = 0;
public var fps:TextField = new TextField();


/** Let the player know what the name of your plugin is. **/
public function get id():String {
return "apitester";
};

public function get target():String {
return "6.0";
}


/** Constructor **/
public function APITester() {
clickButton = new Sprite();
clickButton.addChild(new MuteIcon());
clickButton.y = 10;
clickButton.buttonMode = true;
addChild(clickButton);


startTime = getTimer();
addChild(fps);


};


/** Called by the player after the plugin has been created. **/
public function initPlugin(player:IPlayer, config:PluginConfig):void {

api = player;

api.addEventListener(Event.ENTER_FRAME, calculateFPS);

api.play();



};

private function calculateFPS(evt:Event):void {

var currentTime:Number = (getTimer() - startTime) / 1000;

framesNumber++;

if (currentTime > 1)
{
fps.text = "FPS: " + (Math.floor((framesNumber/currentTime)*10.0)/10.0);

startTime = getTimer();
framesNumber = 0;
}
};

/** If the player resizes itself, this gets called (including on setup). **/
public function resize(wid:Number, hei:Number):void {
clickButton.x = wid - 50;
}
}

}

0 Community Answers

This question has received the maximum number of answers.