src/js/players/player.jwplayer.js
author veltr
Mon, 23 Apr 2012 19:11:08 +0200
branchnew-model
changeset 875 43629caa77bc
parent 839 4357aac4eb19
child 914 3238d1625df9
permissions -rw-r--r--
Big refactoring of widget files + started migration of segmentwidget

/* To wrap a player the develop should create a new class derived from 
   the IriSP.PopcornReplacement.player and defining the correct functions */

/** jwplayer player wrapper */
IriSP.PopcornReplacement.jwplayer = function(container, options) {
  /* appel du parent pour initialiser les structures communes à tous les players */
  IriSP.PopcornReplacement.player.call(this, container, options);
  
  this.media.duration = options.duration; /* optional */
  
  /* Définition des fonctions de l'API -  */
  this.playerFns = {
    play: function() { return jwplayer(this.container).play(); },
    pause: function() { return jwplayer(this.container).pause(); },
    getPosition: function() { return jwplayer(this.container).getPosition(); },
    seek: function(pos) { return jwplayer(this.container).seek(pos); },
    getMute: function() { return jwplayer(this.container).getMute() },
    setMute: function(p) { return jwplayer(this.container).setMute(p); },
    getVolume: function() { return jwplayer(this.container).getVolume() / 100; },
    setVolume: function(p) { return jwplayer(this.container).setVolume(Math.floor(100*p)); }
  }

  options.events = this.callbacks;

  jwplayer(this.container).setup(options);
};

IriSP.PopcornReplacement.jwplayer.prototype = new IriSP.PopcornReplacement.player("", {});