src/js/players/player.allocine.js
author cavaliet
Tue, 21 Feb 2012 17:26:51 +0100
branchpopcorn-port
changeset 819 9b8e68803f6f
child 822 45083178c1d2
permissions -rw-r--r--
add allocine player, and add an full test with this allocine player.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
819
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     1
/* To wrap a player the develop should create a new class derived from
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     2
the IriSP.PopcornReplacement.player and defining the correct functions */
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     3
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     4
/** allocine player wrapper */
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     5
IriSP.PopcornReplacement.allocine = function(container, options) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     6
    console.log("Calling allocine player");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     7
    /* appel du parent pour initialiser les structures communes à tous les players */
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     8
    IriSP.PopcornReplacement.player.call(this, container, options);   
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
     9
    
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    10
    var _this = this;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    11
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    12
    /* Définition des fonctions de l'API -  */
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    13
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    14
    this.playerFns = {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    15
        play : function() {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    16
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    17
                console.log("ask play _this.player = " + _this.player);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    18
                return _this.player.sendToActionScript("play");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    19
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    20
                return false;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    21
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    22
        },
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    23
        pause : function() {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    24
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    25
                console.log("ask pause _this.player = " + _this.player);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    26
                return _this.player.sendToActionScript("pause");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    27
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    28
                return false;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    29
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    30
        },
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    31
        getPosition : function() {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    32
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    33
                return _this.player.sendToActionScript("getSeek","return");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    34
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    35
                return 0;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    36
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    37
        },
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    38
        seek : function(pos) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    39
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    40
                return _this.player.sendToActionScript("seek",pos);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    41
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    42
                return false;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    43
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    44
        },
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    45
        getMute : function() {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    46
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    47
                return _this.player.sendToActionScript("getMute","return");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    48
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    49
                return false;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    50
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    51
        },
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    52
        setMute : function(p) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    53
            if (_this.player) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    54
                //return p ? _this.player.sendToActionScript("setMute") : _this.player.sendToActionScript("setMute");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    55
            	_this.player.sendToActionScript("setMute");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    56
            } else {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    57
                return false;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    58
            }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    59
        }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    60
    }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    61
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    62
    window.onReady = IriSP.wrap(this, this.ready);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    63
    //NOT CALLED window.onAllocineStateChange = IriSP.wrap(this, this.stateHandler);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    64
    window.onTime = IriSP.wrap(this, this.progressHandler);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    65
    
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    66
    var fv = "adVast=false&lg=fr_cinecast&autoPlay="+options.autoPlay+"&directVideoTitle= &urlAcData="+options.urlAcData+"&directVideoPath="+options.directVideoPath+"&host=http://allocine.fr";
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    67
    console.log("fv = " + fv);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    68
    
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    69
    var params = {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    70
        "allowScriptAccess" : "always",
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    71
        "wmode": "opaque",
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    72
        "flashvars" : fv
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    73
    };
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    74
    var atts = {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    75
        id : this.container
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    76
    };
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    77
    swfobject.embedSWF(options.acPlayerUrl, this.container, options.width, options.height, "8", null, null, params, atts);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    78
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    79
};
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    80
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    81
IriSP.PopcornReplacement.allocine.prototype = new IriSP.PopcornReplacement.player("", {});
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    82
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    83
IriSP.PopcornReplacement.allocine.prototype.ready = function() {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    84
    this.player = document.getElementById(this.container);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    85
    this.player.addEventListener("onStateChange", "onAllocineStateChange");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    86
    this.player.addEventListener("onVideoProgress", "onAllocineVideoProgress");
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    87
    this.player.cueVideoByUrl(this._options.video);
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    88
    this.callbacks.onReady();
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    89
};
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    90
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    91
IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    92
    this.callbacks.onTime({
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    93
        position: progressInfo.mediaTime
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    94
    });
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    95
}
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    96
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    97
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    98
IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
    99
    
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   100
    switch(state) {
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   101
        case 1:
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   102
            this.callbacks.onPlay();
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   103
            break;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   104
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   105
        case 2:
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   106
            this.callbacks.onPause();
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   107
            break;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   108
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   109
        case 3:
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   110
            this.callbacks.onSeek({
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   111
                position: this.player.getCurrentTime()
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   112
            });
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   113
            break;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   114
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   115
        /*
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   116
        case 5:
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   117
            this.callbacks.onReady();
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   118
            break;
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   119
        */
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   120
    }
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   121
    
9b8e68803f6f add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff changeset
   122
};