src/widgets/PopcornPlayer.js
changeset 1069 2409cb4cebaf
parent 1068 7623f9af9272
child 1072 ac1eacb3aa33
--- a/src/widgets/PopcornPlayer.js	Fri Oct 02 11:27:17 2015 +0200
+++ b/src/widgets/PopcornPlayer.js	Mon Dec 28 15:50:04 2015 +0100
@@ -18,10 +18,9 @@
         this.video = this.url_transform(this.video);
     }
 
-    if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
-        /* VIMEO */
-        var _popcorn = Popcorn.vimeo(this.container, this.video);
-    } else if (/^(https?:\/\/)?(www\.)?youtube\.com/.test(this.video)) {
+    var _url = this.video;
+
+    if (/^(https?:\/\/)?(www\.)?youtube\.com/.test(this.video)) {
         /* YOUTUBE */
         var _urlparts = this.video.split(/[?&]/),
             _params = {};
@@ -36,34 +35,34 @@
         }
         _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
 
-        var _popcorn = Popcorn.youtube(this.container, _url);
+    }// else {
+    //     /* DEFAULT HTML5 */
+    //     var _tmpId = IriSP._.uniqueId("popcorn"),
+    //         _videoEl = IriSP.jQuery('<video>');
+    //     _videoEl.attr({
+    //         id : _tmpId,
+    //         width : this.width,
+    //         height : this.height || undefined
+    //     });
+    //     if(typeof this.video === "string"){
+    //         _videoEl.attr("src",this.video);
+    //     } else {
+    //         for (var i = 0; i < this.video.length; i++) {
+    //             var _srcNode = IriSP.jQuery('<source>');
+    //             _srcNode.attr({
+    //                 src: this.video[i].src,
+    //                 type: this.video[i].type
+    //             });
+    //             _videoEl.append(_srcNode);
+    //         }
+    //     }
+    //     this.$.html(_videoEl);
+    // }
 
-    } else {
-        /* DEFAULT HTML5 */
-        var _tmpId = IriSP._.uniqueId("popcorn"),
-            _videoEl = IriSP.jQuery('<video>');
-        _videoEl.attr({
-            id : _tmpId,
-            width : this.width,
-            height : this.height || undefined
-        });
-        if(typeof this.video === "string"){
-            _videoEl.attr("src",this.video);
-        } else {
-            for (var i = 0; i < this.video.length; i++) {
-                var _srcNode = IriSP.jQuery('<source>');
-                _srcNode.attr({
-                    src: this.video[i].src,
-                    type: this.video[i].type
-                });
-                _videoEl.append(_srcNode);
-            }
-        }
-        this.$.html(_videoEl);
-        var _popcorn = Popcorn("#" + _tmpId);
-        if (this.autostart || this.autoplay) {
-            _popcorn.autoplay(true);
-        }
+    var _popcorn = Popcorn.smart("#"+this.container, _url);
+
+    if (this.autostart || this.autoplay) {
+        _popcorn.autoplay(true);
     }
 
     var _media = this.media;
@@ -125,7 +124,7 @@
         _media.trigger("volumechange");
     });
 
-    _popcorn.on("play", function() {
+    _popcorn.on("play", function(e) {
         _media.trigger("play");
     });