Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the Javascript to use classes #31

Open
mithro opened this issue Mar 16, 2013 · 4 comments
Open

Refactor the Javascript to use classes #31

mithro opened this issue Mar 16, 2013 · 4 comments
Labels

Comments

@mithro
Copy link
Member

mithro commented Mar 16, 2013

No description provided.

@mithro
Copy link
Member Author

mithro commented Mar 16, 2013

/**
-*- 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;
  }
}

@rihenperry
Copy link
Contributor

#60 since streaming-system project is switching to html5 video support JWPlayer should be deprecated and this issue should be closed

@mithro
Copy link
Member Author

mithro commented Mar 17, 2014

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.

@rihenperry
Copy link
Contributor

@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//issues/31#issuecomment-37778103
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants