source tag for video tag in mashup html code. new-model
authorcavaliet
Thu, 02 Aug 2012 18:25:30 +0200
branchnew-model
changeset 933 8604bc7b4712
parent 930 165f236e42f2
child 934 aa1ede2e2c29
source tag for video tag in mashup html code.
sbin/build/compil.sh
src/js/players/player.mashup-html.js
test/mashup/player-html.htm
--- a/src/js/players/player.mashup-html.js	Fri Jul 27 19:22:54 2012 +0200
+++ b/src/js/players/player.mashup-html.js	Thu Aug 02 18:25:30 2012 +0200
@@ -20,10 +20,10 @@
         if (typeof options.url_transform === "function") {
             _videoUrl = options.url_transform(_videoUrl);
         }
-        
+		
         _videoEl
             .attr({
-                src : _videoUrl,
+                //src : _videoUrl,
                 id : _tmpId,
                 width : _w,
                 height : _h
@@ -33,7 +33,19 @@
                 top: 0,
                 left: 0
             });
-
+        
+        if(typeof _videoUrl === "string"){
+        	_videoEl.attr({src : _videoUrl});
+	    }
+        else{
+        	// _videoUrl is an array of {src:"u",type:"m"}
+        	l = _videoUrl.length;
+        	for (var _i = 0; _i < l; _i++) {
+        		srcNode = IriSP.jQuery('<source>');
+        		srcNode.attr({src:_videoUrl[_i]["src"], type:_videoUrl[_i]["type"]});
+        		_videoEl.append(srcNode);
+            }
+	    }
         _this.$.append(_videoEl);
         _media.videoEl = _videoEl;
         _media.popcorn = Popcorn("#" + _tmpId);
--- a/test/mashup/player-html.htm	Fri Jul 27 19:22:54 2012 +0200
+++ b/test/mashup/player-html.htm	Thu Aug 02 18:25:30 2012 +0200
@@ -48,13 +48,36 @@
         </div>
     <script type="text/javascript">
 
+function url_transform_func(_url){
+	//_url = "rtmp://media.iri.centrepompidou.fr/ddc_player/mp4:video/ldtplatform/rsln_clay_shirky";
+	// We change the streamer if needed
+    var _transformed = _url.replace(/^rtmp:\/\/media.iri.centrepompidou.fr\/ddc_player\/(mp4:)?video\//i,"http://media.iri.centrepompidou.fr/video/");
+	// Get the file name (= remove extension if necessary)
+	ext = _transformed.substr(_transformed.lastIndexOf('.')+1).toLowerCase();
+	if(ext=="mp4" || ext=="f4v" || ext=="flv" || ext=="mov" || ext=="webm" || ext=="mpg4" || ext=="ogv" || ext=="ogg" || ext=="avi"){
+		_transformed = _transformed.substr(0, _transformed.lastIndexOf('.'));
+	}
+	// now that the file name is clean, we add all the extension and mimetype
+	srcTypeArray = [
+	   {src:_transformed+".mp4", type:"video/mp4"},
+	   {src:_transformed+".ogv", type:"video/ogg"},
+	   {src:_transformed+".webm", type:"video/webm"}
+	];
+    console.log("_transformed = " + srcTypeArray[0]["src"]);
+    return srcTypeArray;
+}
+    
+    
 IriSP.libFiles.defaultDir = "../libs/";
 IriSP.widgetsDir = "../metadataplayer";
 IriSP.language = 'fr';
 var _metadata = {
-    url: 'bab_files/mashup.json',
+//    url: 'bab_files/mashup.json',
 //    url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/b2754186-a0c9-11e0-b8bd-00145ea49a02?callback=?',
 //    url: 'http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/5afd8bbe-9b75-11e1-9e5d-00145ea4a2be?callback=?',
+//	  url: 'http://localhost/pf/ldtplatform/ldt/mashupbytag/?tag=projection',
+    url: 'http://localhost/pf/ldtplatform/ldt/mashupbytag/?tag=mashuptag',
+//    url: 'http://localhost/pf/ldtplatform/ldt/mashupbytag/?tag=mashuptag&in=240000&out=1860000',
     format: 'ldt'
 };
 var _canPlayMp4 = document.createElement('video').canPlayType('video/mp4');
@@ -94,16 +117,7 @@
     },
     player:{
         type:'mashup-html',
-        url_transform: function(_url) {
-            var _transformed = _url.replace(/^rtmp:\/\/media.iri.centrepompidou.fr\/ddc_player\/(mp4:)?video\//i,"http://media.iri.centrepompidou.fr/video/");
-            if (!/\.mp4$/.test(_transformed)) {
-                _transformed += '.mp4';
-            }
-            if (_canPlayMp4 == "") {
-                _transformed = _transformed.replace(/\.mp4$/i,'.ogv');
-            }
-            return _transformed;
-        },
+        url_transform: url_transform_func,
         height: 350,
         width: 630,
         metadata: _metadata