Refactor the Javascript to use classes
/**
-*- coding: utf-8 -*-
* vim: set ts=2 sw=2 et sts=2 ai:
*/
function JWPlayer(group, mode, quality) {
this.group = group;
this.jwsettings = {
autostart: true,
mute: true,
//skin: '/static/third_party/jwplayer/skin/glow.zip',
modes: streamer_{{group|safe_js}}.modes(mode, quality),
width: '250',
height: '200'
};
player_jwobject = jwplayer(group).setup(jwsettings);
player_jwobject.onReady(this.updateSize);
this.lastState = null;
this.lastStateChange = 0;
}
function updateSize() {
var player_sizer = $("#"+this.group);
this.jwobject.resize(player_sizer.width(), player_sizer.height());
}
function checkState() {
var state = this.jwobject.getState();
var now = new Date().getTime();
switch(state) {
case this.jwobject.BUFFERING:
if (state - now > 30) {
this.reset();
}
break;
}
if (this.lastState != state) {
this.lastStateChange = now;
this.lastState = state;
}
}
https://github.com/timvideos/streaming-system/issues/60 since streaming-system project is switching to html5 video support JWPlayer should be deprecated and this issue should be closed
Refactoring the code to use javascript classes is independent of which video player the project ends up using. Using javascript classes is generally good style.
@mithro, yeah that is correct.Also trying to minimize global variables creation and avoiding namespace confliction self-executing anonymous functions can also be used in modules.This is one of the best practices recommended by Douglas Crockford in his "Javascript:The Good Parts" book.
On Mon, Mar 17, 2014 at 6:42 AM, Tim Ansell [email protected]:
Refactoring the code to use javascript classes is independent of which video player the project ends up using. Using javascript classes is generally good style.
— Reply to this email directly or view it on GitHubhttps://github.com/timvideos/streaming-system/issues/31#issuecomment-37778103 .