src/widgets/AutoPlayer.js
branchplatform-restapi
changeset 976 4b9ec475026a
parent 959 ee11ed1b739e
child 979 ff62016e051d
equal deleted inserted replaced
975:35aadec4131b 976:4b9ec475026a
    16     
    16     
    17     var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ],
    17     var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ],
    18         _opts = {},
    18         _opts = {},
    19         _types = [
    19         _types = [
    20             {
    20             {
       
    21                 regexp: /^rtmp:\/\//,
       
    22                 type: "JwpPlayer"
       
    23             },
       
    24             {
       
    25                 regexp: /\.(mp4|m4v)$/,
       
    26                 type: "AdaptivePlayer"
       
    27             },
       
    28             {
    21                 regexp: /\.(ogg|ogv|webm)$/,
    29                 regexp: /\.(ogg|ogv|webm)$/,
    22                 type: "PopcornPlayer"
    30                 type: "PopcornPlayer"
    23             },
    31             },
    24             {
    32             {
    25                 regexp: /^(https?:\/\/)?(www\.)?youtube\.com/,
    33                 regexp: /^(https?:\/\/)?(www\.)?youtube\.com/,
    31             },
    39             },
    32             {
    40             {
    33                 regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/,
    41                 regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/,
    34                 type: "DailymotionPlayer"
    42                 type: "DailymotionPlayer"
    35             }
    43             }
    36         ];
    44         ],
       
    45         _rtmprgx = /^rtmp:\/\//;
    37     
    46     
    38     for (var i = 0; i < _types.length; i++) {
    47     for (var i = 0; i < _types.length; i++) {
    39         if (_types[i].regexp.test(this.video)) {
    48         if (_types[i].regexp.test(this.video)) {
    40             _opts.type =  _types[i].type
    49             _opts.type =  _types[i].type
    41         }
    50         }
    43     
    52     
    44     if (typeof _opts.type === "undefined") {
    53     if (typeof _opts.type === "undefined") {
    45         _opts.type = this.default_type
    54         _opts.type = this.default_type
    46     }
    55     }
    47     
    56     
       
    57     if (_rtmprgx.test(this.video)) {
       
    58         _opts.provider = "rtmp";
       
    59         _opts.live = true;
       
    60     }
       
    61     
    48     for (var i = 0; i < _props.length; i++) {
    62     for (var i = 0; i < _props.length; i++) {
    49         if (typeof this[_props[i]] !== "undefined") {
    63         if (typeof this[_props[i]] !== "undefined") {
    50             _opts[_props[i]] = this[_props[i]];
    64             _opts[_props[i]] = this[_props[i]];
    51         }
    65         }
    52     }
    66     }
    53     
       
    54 
    67 
    55     this.insertSubwidget(this.$, _opts);
    68     this.insertSubwidget(this.$, _opts);
    56     
    69     
    57 }
    70 }