src/widgets/AdaptivePlayer.js
author cavaliet
Thu, 02 Jan 2014 16:40:25 +0100
branchnew-model
changeset 1019 3ab36f402b0c
permissions -rw-r--r--
update widgets after enhance in annotation platform.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1019
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     1
IriSP.Widgets.AdaptivePlayer = function(player, config) {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     2
    IriSP.Widgets.Widget.call(this, player, config);
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     3
};
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     4
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     5
IriSP.Widgets.AdaptivePlayer.prototype = new IriSP.Widgets.Widget();
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     6
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     7
IriSP.Widgets.AdaptivePlayer.prototype.defaults = {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     8
    mime_type: "video/mp4",
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
     9
    normal_player: "HtmlPlayer",
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    10
    fallback_player: "JwpPlayer"
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    11
};
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    12
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    13
IriSP.Widgets.AdaptivePlayer.prototype.draw = function() {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    14
    
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    15
    if (typeof this.video === "undefined") {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    16
        this.video = this.media.video;
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    17
    }
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    18
    
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    19
    var _props = [ "autostart", "video", "height", "width", "url_transform" ],
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    20
        _opts = {},
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    21
        _canPlayType = document.createElement('video').canPlayType(this.mime_type);
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    22
    
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    23
    _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? this.normal_player : this.fallback_player;
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    24
    
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    25
    for (var i = 0; i < _props.length; i++) {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    26
        if (typeof this[_props[i]] !== "undefined") {
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    27
            _opts[_props[i]] = this[_props[i]];
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    28
        }
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    29
    }
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    30
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    31
    this.insertSubwidget(this.$, _opts);
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    32
    
3ab36f402b0c update widgets after enhance in annotation platform.
cavaliet
parents:
diff changeset
    33
};