no reload video and hash management
authorcavaliet
Tue, 22 Oct 2013 18:16:12 +0200
changeset 10 4501548c3e5a
parent 9 d22885042ac0
child 11 75419dc974b1
no reload video and hash management
web/index.html
--- a/web/index.html	Tue Oct 22 17:47:08 2013 +0200
+++ b/web/index.html	Tue Oct 22 18:16:12 2013 +0200
@@ -85,6 +85,8 @@
   <script type="text/javascript" src="./lib/bootstrap/js/bootstrap.min.js"></script>
   <script type="text/javascript">
     
+    var cur_vid = "";
+  
     var iframes = {
       "0" : "<iframe src='http://ldt.iri.centrepompidou.fr//ldtplatform/ldt/embediframe/?content_id=37903d3c-3b21-11e3-9592-00145ea4a2be&project_id=49bd6124-3b21-11e3-a863-00145ea4a2be&createannotation=True&tag_titles=&polemic=all&annotations_list=True&autostart=True&annotation=True' width='570' height='1300' seamless='seamless'></iframe>",
       "1" : "<p>iframe à venir, vidéo n°1</p>",
@@ -121,111 +123,119 @@
       if(!(typeof segid !== 'undefined' && segid !== false)){
     	  segid = "";
       }
-
-      if (n=="1" || n=="2" || n=="3" || n=="4" || n=="5" || n=="6" || n=="7"){
-        $("#videocontainer").html("<p>à venir, vidéo n°" + n + "</p>");
+      
+      var fire_hash_changed = false;
+      
+      if(cur_vid!=n){
+	      if (n=="1" || n=="2" || n=="3" || n=="4" || n=="5" || n=="6" || n=="7"){
+	        $("#videocontainer").html("<p>à venir, vidéo n°" + n + "</p>");
+	      }
+	      else{
+	        var s = ''
+	 + '<div>'
+	 + '  <div style="float:left; width:550px;" id="wrapper_player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be">'
+	 + '    <div>'
+	 + '      <div id="player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be_embed" class="iri_player_embed"></div>'
+	 + '      <script type="text/javascript" src="./lib/metadataplayer/LdtPlayer-core.js"><\/script>'
+	 + '      <script type="text/javascript">'
+	 + 'if (typeof jQuery == "undefined") {'
+	 + '    jQuery = IriSP.jQuery;'
+	 + '   }'
+	 + '    var metadatas = {metadata: {url: "./json/data__NUM_JSON__.json"}};'
+	 + '    var metadata_key = "metadata";'
+	 + '  IriSP.libFiles.defaultDir = "./js";'
+	 + '  IriSP.libFiles.locations.jwPlayerSWF = "./player.swf";'
+	 + '  IriSP.libFiles.locations.cssjQueryUI = "./css/jquery-ui.css";'
+	 + '  IriSP.language = "fr-fr";'
+	 + '  IriSP.widgetsDir = "./lib/metadataplayer";'
+	 + '  var _metadata = {'
+	 + '      url: metadatas[metadata_key].url,'
+	 + '      format: "ldt"'
+	 + '  };'
+	 + '  var _config = {'
+	 + '      width: "550",'
+	 + '      container: "player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be_embed",'
+	 + '      css: "./lib/metadataplayer/LdtPlayer-core.css",'
+	 + '      default_options: {'
+	 + '          metadata: _metadata'
+	 + '      },'
+	 + '      widgets: ['
+	 + '          {'
+	 + '              type: "AutoPlayer",'
+	 + '              height: "300",'
+	 + '              autostart:  true,'
+	 + '              url_transform: function(url) { if(url.substr(url.length - 4).toLowerCase()==".flv"){ return url.replace("/ddc_player/video/","/ddc_player/flv:video/"); } return url.replace("/ddc_player/video/","/ddc_player/mp4:video/"); }'
+	 + '          }'
+	 + '          ,{'
+	 + '              type: "Polemic",'
+	 + '              annotation_type: false,'
+	 + '              defaultcolor: "#585858",'
+	 + '              foundcolor: "#fc00ff",'
+	 + '              polemics : ['
+	 + '                      {'
+	 + '                          "name" : "OK",'
+	 + '                          "keywords" : [ "++" ],'
+	 + '                          "color" : "#1d973d"'
+	 + '                      },'
+	 + '                      {'
+	 + '                          "name" : "KO",'
+	 + '                          "keywords" : [ "--" ],'
+	 + '                          "color" : "#ce0a15"'
+	 + '                      },'
+	 + '                      {'
+	 + '                          "name" : "REF",'
+	 + '                          "keywords" : [ "==", "http://" ],'
+	 + '                          "color" : "#c5a62d"  '
+	 + '                      },'
+	 + '                      {'
+	 + '                          "name" : "Q",'
+	 + '                          "keywords" : [ "?" ],'
+	 + '                          "color" : "#036aae"'
+	 + '                      }'
+	 + '                  ]'
+	 + '          }'
+	 + '          ,{'
+	 + '              type: "Slider"'
+	 + '          }'
+	 /*+ '          ,{'
+	 + '              type: "AnnotationsList",'
+	 + '              container: "AnnotationsList_ext",'
+	 + '              ajax_url: "http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/1.0/segments/bytimecode/{{media}}/{{begin}}/{{end}}",'
+	 + '              ajax_granularity : 300000,'
+	 + '              default_thumbnail : "./css/imgs/video_sequence.png",'
+	 + '              show_audio: true,'
+	 + '              rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/"'
+	 + '          }'*/
+	 + '          ,{'
+	 + '              type: "Controller"'
+	 + '          }'
+	 + '          ,{'
+	// + '              type: "Segments",'
+	// + '              annotation_type: ["chap","découpage"]'
+	 + '              type: "MultiSegments"'
+	 + '          }'
+	// + '          ,{'
+	// + '              type: "Annotation"'
+	// + '          }'
+	 + '          ,{'
+	 + '              type: "Mediafragment"'
+	 + '          }'
+	 + '      ]'
+	 + '  };'
+	 + '  _myPlayer = new IriSP.Metadataplayer(_config);'
+	 + '      <\/script>'
+	 + '    </div>'
+	 + '  </div>'
+	 + '  <div style="float:left; width:400px;" id="AnnotationsList_ext"></div>'
+	 + '</div>'
+	 + '<div><p class="text-right"><a style="margin-top: 10px;" class="btn btn-info" href="#" onclick="displayIframe(\'__NUM_JSON__\');return false;"><i class="glyphicon glyphicon-comment"></i> Ajouter votre commentaire sur cette vidéo</a></p></div>';
+	      
+	        $("#videocontainer").html(s.replace(/__NUM_JSON__/g, n));
+	      }
+	      cur_vid = n;
       }
       else{
-        var s = ''
- + '<div>'
- + '  <div style="float:left; width:550px;" id="wrapper_player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be">'
- + '    <div>'
- + '      <div id="player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be_embed" class="iri_player_embed"></div>'
- + '      <script type="text/javascript" src="./lib/metadataplayer/LdtPlayer-core.js"><\/script>'
- + '      <script type="text/javascript">'
- + 'if (typeof jQuery == "undefined") {'
- + '    jQuery = IriSP.jQuery;'
- + '   }'
- + '    var metadatas = {metadata: {url: "./json/data__NUM_JSON__.json"}};'
- + '    var metadata_key = "metadata";'
- + '  IriSP.libFiles.defaultDir = "./js";'
- + '  IriSP.libFiles.locations.jwPlayerSWF = "./player.swf";'
- + '  IriSP.libFiles.locations.cssjQueryUI = "./css/jquery-ui.css";'
- + '  IriSP.language = "fr-fr";'
- + '  IriSP.widgetsDir = "./lib/metadataplayer";'
- + '  var _metadata = {'
- + '      url: metadatas[metadata_key].url,'
- + '      format: "ldt"'
- + '  };'
- + '  var _config = {'
- + '      width: "550",'
- + '      container: "player_project_a94ee060-49e9-11e2-b4ad-00145ea4a2be_embed",'
- + '      css: "./lib/metadataplayer/LdtPlayer-core.css",'
- + '      default_options: {'
- + '          metadata: _metadata'
- + '      },'
- + '      widgets: ['
- + '          {'
- + '              type: "AutoPlayer",'
- + '              height: "300",'
- + '              autostart:  true,'
- + '              url_transform: function(url) { if(url.substr(url.length - 4).toLowerCase()==".flv"){ return url.replace("/ddc_player/video/","/ddc_player/flv:video/"); } return url.replace("/ddc_player/video/","/ddc_player/mp4:video/"); }'
- + '          }'
- + '          ,{'
- + '              type: "Polemic",'
- + '              annotation_type: false,'
- + '              defaultcolor: "#585858",'
- + '              foundcolor: "#fc00ff",'
- + '              polemics : ['
- + '                      {'
- + '                          "name" : "OK",'
- + '                          "keywords" : [ "++" ],'
- + '                          "color" : "#1d973d"'
- + '                      },'
- + '                      {'
- + '                          "name" : "KO",'
- + '                          "keywords" : [ "--" ],'
- + '                          "color" : "#ce0a15"'
- + '                      },'
- + '                      {'
- + '                          "name" : "REF",'
- + '                          "keywords" : [ "==", "http://" ],'
- + '                          "color" : "#c5a62d"  '
- + '                      },'
- + '                      {'
- + '                          "name" : "Q",'
- + '                          "keywords" : [ "?" ],'
- + '                          "color" : "#036aae"'
- + '                      }'
- + '                  ]'
- + '          }'
- + '          ,{'
- + '              type: "Slider"'
- + '          }'
- /*+ '          ,{'
- + '              type: "AnnotationsList",'
- + '              container: "AnnotationsList_ext",'
- + '              ajax_url: "http://ldt.iri.centrepompidou.fr/ldtplatform/api/ldt/1.0/segments/bytimecode/{{media}}/{{begin}}/{{end}}",'
- + '              ajax_granularity : 300000,'
- + '              default_thumbnail : "./css/imgs/video_sequence.png",'
- + '              show_audio: true,'
- + '              rtmp_streamer: "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/"'
- + '          }'*/
- + '          ,{'
- + '              type: "Controller"'
- + '          }'
- + '          ,{'
-// + '              type: "Segments",'
-// + '              annotation_type: ["chap","découpage"]'
- + '              type: "MultiSegments"'
- + '          }'
-// + '          ,{'
-// + '              type: "Annotation"'
-// + '          }'
- + '          ,{'
- + '              type: "Mediafragment"'
- + '          }'
- + '      ]'
- + '  };'
- + '  _myPlayer = new IriSP.Metadataplayer(_config);'
- + '      <\/script>'
- + '    </div>'
- + '  </div>'
- + '  <div style="float:left; width:400px;" id="AnnotationsList_ext"></div>'
- + '</div>'
- + '<div><p class="text-right"><a style="margin-top: 10px;" class="btn btn-info" href="#" onclick="displayIframe(\'__NUM_JSON__\');return false;"><i class="glyphicon glyphicon-comment"></i> Ajouter votre commentaire sur cette vidéo</a></p></div>';
-      
-        $("#videocontainer").html(s.replace(/__NUM_JSON__/g, n));
+    	  fire_hash_changed = true;
       }
       
       // update history
@@ -233,6 +243,9 @@
       if(update_h){
     	if(segid!=""){
     		update_history("v=" + n + "&id=" + segid);
+    		if(fire_hash_changed){
+    			$(window).trigger('hashchange');
+    		}
     	}
     	else{
           update_history("v=" + n);
@@ -261,8 +274,6 @@
     // on load
     $(function() {
       $(".videolink").click(function(e){
-    	console.log('$(this).attr("data-segid")');
-    	console.log($(this).attr("data-segid"));
         playVideo($(this).attr("data-videoid"), $(this).attr('data-segid'));
       });
       // load first video with get parameter