103 |
103 |
104 |
104 |
105 |
105 |
106 |
106 |
107 |
107 |
108 IriSP.init = function (config){ |
108 IriSP.init = function ( config ) { |
109 |
109 |
110 |
110 |
111 if(config === null){ |
111 if ( config === null ) { |
112 |
|
113 IriSP.config = IriSP.configDefault; |
112 IriSP.config = IriSP.configDefault; |
114 |
|
115 } else { |
113 } else { |
116 |
114 |
117 IriSP.config = config; |
115 IriSP.config = config; |
118 |
116 |
119 |
117 if ( IriSP.config.player.params == null ) { |
120 |
118 IriSP.config.player.params = IriSP.configDefault.player.params; |
121 if (IriSP.config.player.params == null){ |
119 } |
122 IriSP.config.player.params = IriSP.configDefault.player.params;} |
120 |
123 |
121 if ( IriSP.config.player.flashvars == null ) { |
124 if (IriSP.config.player.flashvars == null){ |
122 IriSP.config.player.flashvars = IriSP.configDefault.player.flashvars; |
125 IriSP.config.player.flashvars = IriSP.configDefault.player.flashvars;} |
123 } |
126 if (IriSP.config.player.attributes == null){ |
124 |
127 IriSP.config.player.attributes = IriSP.configDefault.player.attributes;} |
125 if ( IriSP.config.player.attributes == null ) { |
|
126 IriSP.config.player.attributes = IriSP.configDefault.player.attributes; |
|
127 } |
128 } |
128 } |
129 |
129 |
130 var metadataSrc = IriSP.config.metadata.src; |
130 var metadataSrc = IriSP.config.metadata.src; |
131 var guiContainer = IriSP.config.gui.container; |
131 var guiContainer = IriSP.config.gui.container; |
132 var guiMode = IriSP.config.gui.mode; |
132 var guiMode = IriSP.config.gui.mode; |
133 var guiLdtShareTool = IriSP.LdtShareTool; |
133 var guiLdtShareTool = IriSP.LdtShareTool; |
|
134 |
134 // Localize jQuery variable |
135 // Localize jQuery variable |
135 IriSP.jQuery = null; |
136 IriSP.jQuery = null; |
136 |
137 |
137 /******** Load jQuery if not present *********/ |
138 /******** Load jQuery if not present *********/ |
138 if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { |
139 if ( window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2' ) { |
139 var script_tag = document.createElement('script'); |
140 |
140 script_tag.setAttribute("type","text/javascript"); |
141 var script_tag = document.createElement( 'script' ); |
141 script_tag.setAttribute("src",IriSP.lib.jQuery); |
142 script_tag.setAttribute( "type", "text/javascript" ); |
142 //"http://cdn.jquerytools.org/1.2.4/full/jquery.tools.min.js"); |
143 script_tag.setAttribute( "src", IriSP.lib.jQuery ); |
|
144 |
143 script_tag.onload = scriptLibHandler; |
145 script_tag.onload = scriptLibHandler; |
144 script_tag.onreadystatechange = function () { // Same thing but for IE |
146 script_tag.onreadystatechange = function () { // Same thing but for IE |
145 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
147 if ( this.readyState == 'complete' || this.readyState == 'loaded' ) { |
146 scriptLibHandler(); |
148 scriptLibHandler(); |
147 |
|
148 } |
149 } |
149 }; |
150 }; |
|
151 |
150 // Try to find the head, otherwise default to the documentElement |
152 // Try to find the head, otherwise default to the documentElement |
151 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); |
153 ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_tag ); |
152 } else { |
154 } else { |
153 // The jQuery version on the window is the one we want to use |
155 // The jQuery version on the window is the one we want to use |
154 IriSP.jQuery = window.jQuery; |
156 IriSP.jQuery = window.jQuery; |
155 scriptLibHandler(); |
157 scriptLibHandler(); |
156 } |
158 } |
157 |
159 |
158 /******** Called once jQuery has loaded ******/ |
160 /******** Called once jQuery has loaded ******/ |
159 function scriptLibHandler() { |
161 function scriptLibHandler() { |
160 |
162 |
161 var script_jqUi_tooltip = document.createElement('script'); |
163 var script_jqUi_tooltip = document.createElement( 'script' ); |
162 script_jqUi_tooltip.setAttribute("type","text/javascript"); |
164 script_jqUi_tooltip.setAttribute( "type", "text/javascript" ); |
163 script_jqUi_tooltip.setAttribute("src",IriSP.lib.jQueryToolTip); |
165 script_jqUi_tooltip.setAttribute( "src", IriSP.lib.jQueryToolTip ); |
164 script_jqUi_tooltip.onload = scriptLoadHandler; |
166 script_jqUi_tooltip.onload = scriptLoadHandler; |
165 script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE |
167 script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE |
166 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
168 if ( this.readyState == 'complete' || this.readyState == 'loaded' ) { |
167 scriptLoadHandler("jquery.tools.min.js loded"); |
169 scriptLoadHandler( "jquery.tools.min.js loded" ); |
168 } |
170 } |
169 }; |
171 }; |
170 |
172 |
171 var script_swfObj = document.createElement('script'); |
173 var script_swfObj = document.createElement('script'); |
172 script_swfObj.setAttribute("type","text/javascript"); |
174 script_swfObj.setAttribute( "type","text/javascript" ); |
173 script_swfObj.setAttribute("src",IriSP.lib.swfObject); |
175 script_swfObj.setAttribute( "src",IriSP.lib.swfObject ); |
174 script_swfObj.onload = scriptLoadHandler; |
176 script_swfObj.onload = scriptLoadHandler; |
175 script_swfObj.onreadystatechange = function () { // Same thing but for IE |
177 script_swfObj.onreadystatechange = function () { // Same thing but for IE |
176 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
178 if ( this.readyState == 'complete' || this.readyState == 'loaded' ) { |
177 scriptLoadHandler("swfobject.js loded"); |
179 scriptLoadHandler( "swfobject.js loded" ); |
178 } |
180 } |
179 }; |
181 }; |
180 |
182 |
181 var script_jqUi = document.createElement('script'); |
183 var script_jqUi = document.createElement( 'script' ); |
182 script_jqUi.setAttribute("type","text/javascript"); |
184 script_jqUi.setAttribute( "type","text/javascript" ); |
183 script_jqUi.setAttribute("src",IriSP.lib.jQueryUI); |
185 script_jqUi.setAttribute( "src",IriSP.lib.jQueryUI ); |
184 script_jqUi.onload = scriptLoadHandler; |
186 script_jqUi.onload = scriptLoadHandler; |
185 script_jqUi.onreadystatechange = function () { // Same thing but for IE |
187 script_jqUi.onreadystatechange = function () { // Same thing but for IE |
186 if (this.readyState == 'complete' || this.readyState == 'loaded') { |
188 if ( this.readyState == 'complete' || this.readyState == 'loaded' ) { |
187 scriptLoadHandler("jquery-ui.min.js loded"); |
189 scriptLoadHandler( "jquery-ui.min.js loded" ); |
188 } |
190 } |
189 }; |
191 }; |
190 |
192 |
191 |
193 |
192 |
194 ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi_tooltip); |
193 |
195 ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi ); |
194 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi_tooltip); |
196 ( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_swfObj ); |
195 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi); |
|
196 (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_swfObj); |
|
197 |
197 |
198 |
198 |
199 }; |
199 }; |
200 |
200 |
201 /******** Called once all lib are loaded ******/ |
201 /******** Called once all lib are loaded ******/ |
202 var loadLib = 0; |
202 var loadLib = 0; |
203 function scriptLoadHandler(Mylib) { |
203 /* FIXME : ugly */ |
|
204 function scriptLoadHandler( Mylib ) { |
204 //alert(Mylib); |
205 //alert(Mylib); |
205 loadLib +=1; |
206 loadLib +=1; |
206 if(loadLib===3){ |
207 if( loadLib===3 ) { |
207 main(); |
208 main(); |
208 }else { |
|
209 // __IriSP.jQuery('#'+__IriSP.config.gui.container).html("Loading library ..."); |
|
210 } |
209 } |
211 }; |
210 }; |
212 |
211 |
213 /******** Our main function ********/ |
212 /******** Our main function ********/ |
214 function main() { |
213 function main() { |
215 |
214 |
216 |
215 |
217 // Make __IriSP.jQuery and restore window.jQuery |
216 // Make our own IriSP.jQuery and restore window.jQuery if there was one. |
218 IriSP.jQuery = window.jQuery.noConflict(true); |
217 IriSP.jQuery = window.jQuery.noConflict( true ); |
219 // Call MY Jquery |
218 // Call ours Jquery |
220 IriSP.jQuery(document).ready(function($) { |
219 IriSP.jQuery( document ).ready( function($) { |
221 |
220 |
222 /******* Load CSS *******/ |
221 /******* Load CSS *******/ |
223 var css_link_jquery = IriSP.jQuery("<link>", { |
222 var css_link_jquery = IriSP.jQuery( "<link>", { |
224 rel: "stylesheet", |
223 rel: "stylesheet", |
225 type: "text/css", |
224 type: "text/css", |
226 href: IriSP.lib.cssjQueryUI, |
225 href: IriSP.lib.cssjQueryUI, |
227 'class': "dynamic_css" |
226 'class': "dynamic_css" |
228 }); |
227 } ); |
229 var css_link_custom = IriSP.jQuery("<link>", { |
228 var css_link_custom = IriSP.jQuery( "<link>", { |
230 rel: "stylesheet", |
229 rel: "stylesheet", |
231 type: "text/css", |
230 type: "text/css", |
232 href: IriSP.config.gui.css, |
231 href: IriSP.config.gui.css, |
233 'class': "dynamic_css" |
232 'class': "dynamic_css" |
234 }); |
233 } ); |
235 |
234 |
236 css_link_jquery.appendTo('head'); |
235 css_link_jquery.appendTo( 'head' ); |
237 css_link_custom.appendTo('head'); |
236 css_link_custom.appendTo( 'head' ); |
238 |
237 |
239 // to see dynamicly loaded css on IE |
238 // to see dynamicly loaded css on IE |
240 if ($.browser.msie) { |
239 if ( $.browser.msie ) { |
241 $('.dynamic_css').clone().appendTo('head'); |
240 $( '.dynamic_css' ).clone().appendTo( 'head' ); |
242 } |
241 } |
243 |
242 |
244 //__IriSP.trace("main","ready createMyHtml"); |
243 //__IriSP.trace("main","ready createMyHtml"); |
245 |
244 |
246 IriSP.createMyHtml(); |
245 IriSP.createMyHtml(); |
247 //__IriSP.trace("main","end createMyHtml"); |
246 //__IriSP.trace("main","end createMyHtml"); |
248 |
247 |
249 /******* Load Metadata *******/ |
248 /******* Load Metadata *******/ |
250 |
249 /* FIXME : factor it in another file */ |
251 IriSP.jQuery.ajax({ |
250 IriSP.jQuery.ajax({ |
252 dataType: IriSP.config.metadata.load, |
251 dataType: IriSP.config.metadata.load, |
253 url:metadataSrc, |
252 url:metadataSrc, |
254 success : function(json){ |
253 success : function( json ){ |
255 |
254 |
256 IriSP.trace("ajax","success"); |
255 IriSP.trace( "ajax", "success" ); |
257 |
256 |
258 // START PARSING ----------------------- |
257 // START PARSING ----------------------- |
259 if(json === ""){ |
258 if( json === "" ){ |
260 alert("ERREUR DE CHARGEMENT JSON"); |
259 alert( "Json load error" ); |
261 } else { |
260 } else { |
262 |
|
263 |
|
264 // # CREATE MEDIA // |
261 // # CREATE MEDIA // |
265 // # JUSTE ONE PLAYER FOR THE MOMENT // |
262 // # JUSTE ONE PLAYER FOR THE MOMENT // |
266 //__IriSP.jQuery("<div></div>").appendTo("#output"); |
263 //__IriSP.jQuery("<div></div>").appendTo("#output"); |
267 var MyMedia = new __IriSP.Media( |
264 var MyMedia = new __IriSP.Media( |
268 json.medias[0].id, |
265 json.medias[0].id, |
269 json.medias[0].href, |
266 json.medias[0].href, |
270 json.medias[0]['meta']['dc:duration'], |
267 json.medias[0]['meta']['dc:duration'], |
271 json.medias[0]['dc:title'], |
268 json.medias[0]['dc:title'], |
272 json.medias[0]['dc:description']); |
269 json.medias[0]['dc:description']); |
273 |
270 |
274 IriSP.trace("__IriSP.MyApiPlayer", |
271 IriSP.trace( "__IriSP.MyApiPlayer", |
275 IriSP.config.gui.width+" " |
272 IriSP.config.gui.width+" " |
276 + IriSP.config.gui.height + " " |
273 + IriSP.config.gui.height + " " |
277 + json.medias[0].href + " " |
274 + json.medias[0].href + " " |
278 + json.medias[0]['meta']['dc:duration'] + " " |
275 + json.medias[0]['meta']['dc:duration'] + " " |
279 + json.medias[0]['meta']['item']['value']); |
276 + json.medias[0]['meta']['item']['value']); |
280 |
277 |
281 // Create APIplayer |
278 // Create APIplayer |
282 IriSP.MyApiPlayer = new __IriSP.APIplayer( |
279 IriSP.MyApiPlayer = new __IriSP.APIplayer ( |
283 IriSP.config.gui.width, |
280 IriSP.config.gui.width, |
284 IriSP.config.gui.height, |
281 IriSP.config.gui.height, |
285 json.medias[0].href, |
282 json.medias[0].href, |
286 json.medias[0]['meta']['dc:duration'], |
283 json.medias[0]['meta']['dc:duration'], |
287 json.medias[0]['meta']['item']['value']); |
284 json.medias[0]['meta']['item']['value']); |
288 |
285 |
289 // # CREATE THE FIRST LINE // |
286 // # CREATE THE FIRST LINE // |
290 IriSP.trace("__IriSP.init.main","__IriSP.Ligne"); |
287 IriSP.trace( "__IriSP.init.main","__IriSP.Ligne" ); |
291 IriSP.MyLdt = new __IriSP.Ligne ( |
288 IriSP.MyLdt = new __IriSP.Ligne( |
292 json['annotation-types'][0].id, |
289 json['annotation-types'][0].id, |
293 json['annotation-types'][0]['dc:title'], |
290 json['annotation-types'][0]['dc:title'], |
294 json['annotation-types'][0]['dc:description'], |
291 json['annotation-types'][0]['dc:description'], |
295 json.medias[0]['meta']['dc:duration']); |
292 json.medias[0]['meta']['dc:duration']); |
296 |
293 |
297 // CREATE THE TAG CLOUD // |
294 // CREATE THE TAG CLOUD // |
298 IriSP.trace("__IriSP.init.main","__IriSP.Tags"); |
295 IriSP.trace( "__IriSP.init.main","__IriSP.Tags" ); |
299 IriSP.MyTags = new __IriSP.Tags (json.tags); |
296 IriSP.MyTags = new __IriSP.Tags( json.tags ); |
300 |
297 |
301 // CREATE THE ANNOTATIONS // |
298 // CREATE THE ANNOTATIONS // |
302 // JUSTE FOR THE FIRST TYPE // |
299 // JUSTE FOR THE FIRST TYPE // |
303 IriSP.jQuery.each(json.annotations, function(i,item) { |
300 IriSP.jQuery.each( json.annotations, function(i,item) { |
304 if (item.meta['id-ref'] == IriSP.MyLdt.id) { |
301 if (item.meta['id-ref'] == IriSP.MyLdt.id) { |
305 //__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation"); |
302 //__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation"); |
306 IriSP.MyLdt.addAnnotation( |
303 IriSP.MyLdt.addAnnotation( |
307 item.id, |
304 item.id, |
308 item.begin, |
305 item.begin, |
591 this.streamerPath = streamerPath; |
593 this.streamerPath = streamerPath; |
592 this.MySwfPath = MySwfPath; |
594 this.MySwfPath = MySwfPath; |
593 |
595 |
594 IriSP.MyApiPlayer = this; |
596 IriSP.MyApiPlayer = this; |
595 |
597 |
596 IriSP.createPlayer(this.url,this.streamerPath); |
598 IriSP.createPlayer( this.url, this.streamerPath ); |
597 IriSP.trace("__IriSP.APIplayer","__IriSP.createPlayer"); |
599 IriSP.trace( "__IriSP.APIplayer", "__IriSP.createPlayer" ); |
598 |
600 |
599 //__IriSP.config.player |
601 //__IriSP.config.player |
600 /* |
602 /* |
601 - dailymotion // &enableApi=1&chromeless=1 |
603 - dailymotion // &enableApi=1&chromeless=1 |
602 - youtube |
604 - youtube |
603 - html5 |
605 - html5 |
604 - flowplayer |
606 - flowplayer |
605 - jwplayer |
607 - jwplayer |
606 */ |
608 */ |
607 |
609 |
608 } |
610 }; |
609 __IriSP.APIplayer.prototype.ready = function(player){ |
611 |
|
612 __IriSP.APIplayer.prototype.ready = function( player ) { |
610 |
613 |
611 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface"); |
614 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface"); |
612 IriSP.createInterface(this.width,this.height,this.duration); |
615 IriSP.createInterface( this.width, this.height, this.duration ); |
613 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady","END __IriSP.createInterface"); |
616 //__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady","END __IriSP.createInterface"); |
614 |
617 |
615 // hashchange EVENT |
618 // hashchange EVENT |
616 if (window.addEventListener){ |
619 if ( window.addEventListener ){ |
617 |
620 |
618 // pour FIREFOX hashchange EVENT |
621 // for firefox hashchange EVENT |
619 window.addEventListener("hashchange", function() { |
622 window.addEventListener( "hashchange", function() { |
620 var url = window.location.href; |
623 var url = window.location.href; |
621 var time = IriSP.retrieveTimeFragment(url); |
624 var time = IriSP.retrieveTimeFragment( url ); |
622 IriSP.trace("__IriSP.APIplayer.prototype.ready",time); |
625 IriSP.trace( "__IriSP.APIplayer.prototype.ready", time ); |
623 if(IriSP.MyApiPlayer.hashchangeUpdate==null){ |
626 if( IriSP.MyApiPlayer.hashchangeUpdate==null ){ |
|
627 IriSP.MyApiPlayer.seek( time ); |
|
628 |
|
629 } else { |
|
630 IriSP.MyApiPlayer.hashchangeUpdate = null; |
|
631 } |
|
632 }, false ); |
|
633 |
|
634 } else if (window.attachEvent){ |
|
635 // for ie hashchange EVENT |
|
636 window.attachEvent( "onhashchange", function() { |
|
637 IriSP.trace( "hashchange",time ); |
|
638 var url = window.location.href; |
|
639 var time = IriSP.retrieveTimeFragment( url ); |
|
640 if( IriSP.MyApiPlayer.hashchangeUpdate == null ){ |
624 IriSP.MyApiPlayer.seek(time); |
641 IriSP.MyApiPlayer.seek(time); |
625 |
642 } else { |
626 }else{ |
643 IriSP.MyApiPlayer.hashchangeUpdate = null; |
627 IriSP.MyApiPlayer.hashchangeUpdate=null; |
|
628 } |
|
629 }, false); |
|
630 |
|
631 } |
|
632 else if (window.attachEvent){ |
|
633 // FOR IE hashchange EVENT |
|
634 |
|
635 window.attachEvent("onhashchange", function() { |
|
636 IriSP.trace("hashchange",time); |
|
637 var url = window.location.href; |
|
638 var time = IriSP.retrieveTimeFragment(url); |
|
639 if(IriSP.MyApiPlayer.hashchangeUpdate==null){ |
|
640 IriSP.MyApiPlayer.seek(time); |
|
641 }else{ |
|
642 IriSP.MyApiPlayer.hashchangeUpdate=null; |
|
643 } |
644 } |
644 }, false); |
645 }, false); |
645 } |
646 } |
646 |
647 |
647 // Search |
648 // Search |
648 //__IriSP.jQuery("#LdtSearchInput").change(function() {__IriSP.Search(this.value);}); |
649 //__IriSP.jQuery("#LdtSearchInput").change(function() {__IriSP.Search(this.value);}); |
649 //__IriSP.jQuery("#LdtSearchInput").live('change', function(event) {__IriSP.Search(this.value);}); |
650 //__IriSP.jQuery("#LdtSearchInput").live('change', function(event) {__IriSP.Search(this.value);}); |
650 IriSP.jQuery("#LdtSearchInput").keydown(function() {IriSP.Search(this.value);}); |
651 IriSP.jQuery( "#LdtSearchInput" ).keydown( function() { IriSP.Search( this.value );} ); |
651 IriSP.jQuery("#LdtSearchInput").keyup(function() {IriSP.Search(this.value);}); |
652 IriSP.jQuery("#LdtSearchInput").keyup( function() { IriSP.Search( this.value );} ); |
652 |
653 |
653 } |
654 }; |
|
655 |
654 __IriSP.APIplayer.prototype.pause = function(){ |
656 __IriSP.APIplayer.prototype.pause = function(){ |
655 this.hashchangeUpdate = true; |
657 this.hashchangeUpdate = true; |
656 IriSP.player.sendEvent('PAUSE'); |
658 IriSP.player.sendEvent( 'PAUSE' ); |
657 } |
659 }; |
658 __IriSP.APIplayer.prototype.play = function(){ |
660 |
|
661 __IriSP.APIplayer.prototype.play = function() { |
659 this.hashchangeUpdate = true; |
662 this.hashchangeUpdate = true; |
660 //__IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type); |
663 //__IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type); |
661 if(IriSP.config.player.type=='jwplayer'){ |
664 if( IriSP.config.player.type=='jwplayer' ){ |
662 |
665 |
663 IriSP.player.sendEvent('PLAY'); |
666 IriSP.player.sendEvent( 'PLAY' ); |
664 |
667 |
665 } else if(IriSP.config.player.type=='dailymotion' |
668 } else if(IriSP.config.player.type == 'dailymotion' |
666 || IriSP.config.player.type=='youtube') { |
669 || IriSP.config.player.type == 'youtube' ) { |
667 |
670 |
668 var status = IriSP.player.getPlayerState(); |
671 var status = IriSP.player.getPlayerState(); |
669 IriSP.trace("__IriSP.APIplayer.prototype.play.status",status); |
672 IriSP.trace( "__IriSP.APIplayer.prototype.play.status", status); |
670 if (status!=1){ |
673 if ( status != 1 ){ |
671 IriSP.player.playVideo(); |
674 IriSP.player.playVideo(); |
672 }else{ |
675 } else { |
673 IriSP.player.pauseVideo(); |
676 IriSP.player.pauseVideo(); |
674 } |
677 } |
675 } |
678 } |
676 } |
679 }; |
677 __IriSP.APIplayer.prototype.mute = function(){ |
680 |
678 IriSP.player.sendEvent('MUTE'); |
681 __IriSP.APIplayer.prototype.mute = function() { |
|
682 IriSP.player.sendEvent( 'MUTE' ); |
679 |
683 |
680 //alert(__IriSP.jQuery(".ui-icon-volume-on").css("background-position-x")); |
684 //alert(__IriSP.jQuery(".ui-icon-volume-on").css("background-position-x")); |
681 if (IriSP.jQuery(".ui-icon-volume-on").css("background-position")=="-144px -160px"){ |
685 /* FIXME : remove hardcoded values */ |
682 IriSP.jQuery(".ui-icon-volume-on").css("background-position","-130px -160px"); |
686 if ( IriSP.jQuery( ".ui-icon-volume-on" ).css( "background-position" ) == "-144px -160px" ){ |
|
687 IriSP.jQuery(" .ui-icon-volume-on ").css(" background-position ", "-130px -160px"); |
683 } else { |
688 } else { |
684 IriSP.jQuery(".ui-icon-volume-on").css("background-position","-144px -160px"); |
689 IriSP.jQuery( ".ui-icon-volume-on" ).css( "background-position", "-144px -160px" ); |
685 } |
690 } |
686 } |
691 }; |
687 __IriSP.APIplayer.prototype.share = function(network){ |
692 |
688 |
693 /* FIXME : rename */ |
689 var MyMessage = encodeURIComponent("J'écoute Les Retours du Dimanche : "); |
694 __IriSP.APIplayer.prototype.share = function( network ) { |
|
695 |
|
696 /* FIXME : remove hardcoded */ |
|
697 var MyMessage = encodeURIComponent( "J'écoute Les Retours du Dimanche : " ); |
690 var MyURLNow = window.location.href; |
698 var MyURLNow = window.location.href; |
691 var shareURL; |
699 var shareURL = null; |
692 //alert(network+" : "+MyURLNow); |
700 //alert(network+" : "+MyURLNow); |
693 |
701 |
|
702 /* FIXME : use a sharing library */ |
694 if(network == "facebook"){ |
703 if(network == "facebook"){ |
695 shareURL = "http://www.facebook.com/share.php?u="; |
704 shareURL = "http://www.facebook.com/share.php?u="; |
696 }else if(network == "twitter"){ |
705 }else if(network == "twitter"){ |
697 shareURL = "http://twitter.com/home?status="+MyMessage; |
706 shareURL = "http://twitter.com/home?status="+MyMessage; |
698 }else if(network == "myspace"){ |
707 }else if(network == "myspace"){ |
702 }else if(network == "JameSpot"){ |
711 }else if(network == "JameSpot"){ |
703 shareURL = "http://www.jamespot.com/?action=spotit&u="; |
712 shareURL = "http://www.jamespot.com/?action=spotit&u="; |
704 //alert(network+" non actif pour l'instant : "+MyURLNow); |
713 //alert(network+" non actif pour l'instant : "+MyURLNow); |
705 } |
714 } |
706 |
715 |
707 window.open(shareURL+encodeURIComponent(MyURLNow)); |
716 if (shareURL != null) |
|
717 window.open( shareURL+encodeURIComponent(MyURLNow) ); |
708 //window.location.href = shareURL+encodeURIComponent(MyURLNow); |
718 //window.location.href = shareURL+encodeURIComponent(MyURLNow); |
709 } |
719 }; |
710 __IriSP.APIplayer.prototype.seek = function (time){ |
720 |
711 if(time==0){time=1} |
721 __IriSP.APIplayer.prototype.seek = function (time) { |
712 IriSP.trace("__IriSP.APIplayer.prototype.seek",time); |
722 |
713 if(IriSP.config.player.type=='jwplayer'){ |
723 if( time==0 ) { time=1; } |
|
724 |
|
725 IriSP.trace( "__IriSP.APIplayer.prototype.seek", time ); |
|
726 |
|
727 if( IriSP.config.player.type=='jwplayer') { |
714 //__IriSP.MyApiPlayer.play() |
728 //__IriSP.MyApiPlayer.play() |
715 IriSP.player.sendEvent('SEEK', time); |
729 IriSP.player.sendEvent( 'SEEK', time ); |
716 } else if(IriSP.config.player.type=='dailymotion' |
730 } else if( IriSP.config.player.type=='dailymotion' |
717 || IriSP.config.player.type=='youtube') { |
731 || IriSP.config.player.type=='youtube' ) { |
718 IriSP.player.seekTo(time); |
732 IriSP.player.seekTo( time ); |
719 } |
733 } |
720 this.changePageUrlOffset(time); |
734 |
721 } |
735 this.changePageUrlOffset( time ); |
722 __IriSP.APIplayer.prototype.update = function (time){ |
736 }; |
723 if(time!=0){ |
737 |
724 this.hashchangeUpdate = true; |
738 __IriSP.APIplayer.prototype.update = function (time) { |
725 IriSP.trace("__IriSP.APIplayer.prototype.update",time); |
739 |
726 IriSP.player.sendEvent('SEEK', time); |
740 if( time != 0 ) { |
727 } |
741 this.hashchangeUpdate = true; |
728 } |
742 |
729 __IriSP.APIplayer.prototype.changePageUrlOffset = function (time) { |
743 IriSP.trace( "__IriSP.APIplayer.prototype.update" ,time); |
|
744 IriSP.player.sendEvent( 'SEEK', time ); |
|
745 } |
|
746 }; |
|
747 |
|
748 __IriSP.APIplayer.prototype.changePageUrlOffset = function ( time ) { |
730 //alert(time); |
749 //alert(time); |
731 IriSP.trace("__IriSP.APIplayer.prototype.changePageUrlOffset","CHANGE URL "+time); |
750 IriSP.trace( "__IriSP.APIplayer.prototype.changePageUrlOffset" , "CHANGE URL "+ time); |
732 |
751 |
733 window.location.hash = "#t=" + time; |
752 window.location.hash = "#t=" + time; |
734 window.location.href = window.location.href; |
753 window.location.href = window.location.href; |
735 |
754 |
736 } |
755 }; |
737 |
756 |
738 /* MEDIA FRAGMENT FUNCTION by Silvia Pfeiffer */ |
757 /* Media Fragment functionality by Silvia Pfeiffer */ |
739 |
758 |
740 IriSP.jumpToTimeoffset = function (form) { |
759 IriSP.jumpToTimeoffset = function ( form ) { |
741 var time = form.time.value; |
760 var time = form.time.value; |
742 IriSP.MyApiPlayer.changePageUrlOffset(time); |
761 IriSP.MyApiPlayer.changePageUrlOffset( time ); |
743 } |
762 }; |
744 IriSP.retrieveTimeFragment = function (url) { |
763 |
|
764 IriSP.retrieveTimeFragment = function ( url ) { |
745 var pageoffset = 0; |
765 var pageoffset = 0; |
746 var offsettime = 0; |
766 var offsettime = 0; |
747 |
767 |
748 if (url.split("#")[1] != null) { |
768 if ( url.split("#")[1] != null ) { |
749 pageoffset = url.split("#")[1]; |
769 pageoffset = url.split( "#" )[1]; |
750 if (pageoffset.substring(2) != null) { |
770 if ( pageoffset.substring( 2 ) != null ) { |
751 offsettime = pageoffset.substring(2); |
771 offsettime = pageoffset.substring( 2 ); |
752 } |
772 } |
753 } |
773 } |
754 return offsettime; |
774 return offsettime; |
755 } |
775 }; |
756 IriSP.ignoreTimeFragment = function(url){ |
776 |
757 if (url.split("#")[1] != null) { |
777 IriSP.ignoreTimeFragment = function( url ){ |
758 var pageurl= url.split("#")[0]; |
778 |
759 } |
779 var pageurl = url; |
760 return pageurl; |
780 |
761 } |
781 if ( url.split( "#" )[1] != null ) { |
762 |
782 pageurl = url.split( "#" )[0]; |
763 |
783 } |
764 /* CODE SPECIAL JW PLAYER creation + listener */ |
784 |
|
785 return pageurl; |
|
786 }; |
|
787 |
|
788 |
|
789 /* code specific to jwplayer / creation and listener */ |
765 |
790 |
766 IriSP.currentPosition = 0; |
791 IriSP.currentPosition = 0; |
767 IriSP.currentVolume = 50; |
792 IriSP.currentVolume = 50; |
768 IriSP.player = null; |
793 IriSP.player = null; |
769 IriSP.startPosition = null; |
794 IriSP.startPosition = null; |
770 IriSP.firstplay = false; |
795 IriSP.firstplay = false; |
771 |
796 |
772 |
797 |
773 |
798 |
774 IriSP.createPlayer = function (url,streamerPath) { |
799 IriSP.createPlayer = function ( url, streamerPath ) { |
775 |
800 if( IriSP.config.player.type=='dailymotion' ) { |
776 |
|
777 if(IriSP.config.player.type=='dailymotion'){ |
|
778 IriSP.config.player.src = IriSP.config.player.src+"&chromeless=1&enableApi=1"; |
801 IriSP.config.player.src = IriSP.config.player.src+"&chromeless=1&enableApi=1"; |
779 } else if (IriSP.config.player.type=='youtube'){ |
802 } else if ( IriSP.config.player.type=='youtube' ){ |
780 IriSP.config.player.src = IriSP.config.player.src+"&enablejsapi=1&version=3"; |
803 IriSP.config.player.src = IriSP.config.player.src+"&enablejsapi=1&version=3"; |
781 } |
804 } |
782 |
805 |
783 IriSP.trace("__IriSP.createPlayer","start"); |
806 IriSP.trace( "__IriSP.createPlayer", "start" ); |
784 |
807 |
785 IriSP.myUrlFragment = url.split(streamerPath); |
808 IriSP.myUrlFragment = url.split( streamerPath ); |
786 |
809 |
787 var configTemp = IriSP.jQuery.extend(true, {}, IriSP.config); |
810 var configTemp = IriSP.jQuery.extend( true, {}, IriSP.config ); |
788 configTemp.player.flashvars.autostart = "true"; |
811 configTemp.player.flashvars.autostart = "true"; |
789 configTemp.player.flashvars.streamer = streamerPath; |
812 configTemp.player.flashvars.streamer = streamerPath; |
790 configTemp.player.flashvars.file = IriSP.myUrlFragment[1]; |
813 configTemp.player.flashvars.file = IriSP.myUrlFragment[1]; |
791 |
814 |
792 var flashvars = configTemp.player.flashvars; |
815 var flashvars = configTemp.player.flashvars; |
804 swfobject.embedSWF( |
827 swfobject.embedSWF( |
805 IriSP.config.player.src, |
828 IriSP.config.player.src, |
806 "Ldt-PlaceHolder", |
829 "Ldt-PlaceHolder", |
807 IriSP.config.gui.width, |
830 IriSP.config.gui.width, |
808 IriSP.config.gui.height, |
831 IriSP.config.gui.height, |
809 "9.0.115", |
832 "9.0.115", // FIXME : de-hardcode version ? |
810 false, |
833 false, |
811 flashvars, |
834 flashvars, |
812 params, |
835 params, |
813 attributes |
836 attributes |
814 ); |
837 ); |
815 |
838 |
816 // need a methode to |
839 // need a methode to |
817 // re execute if this swf call does'nt work |
840 // re execute if this swf call does'nt work |
818 } |
841 }; |
819 |
842 |
820 |
843 |
821 /* API JW PLAYER */ |
844 /* jw player api */ |
822 IriSP.playerReady = function (thePlayer) { |
845 IriSP.playerReady = function (thePlayer) { |
823 |
846 |
824 //__IriSP.trace("__IriSP.playerReady","PLAYER READY !!!!!!!!!!!!"); |
847 //__IriSP.trace("__IriSP.playerReady","PLAYER READY !!!!!!!!!!!!"); |
825 IriSP.player = window.document[thePlayer.id]; |
848 IriSP.player = window.document[thePlayer.id]; |
826 //__IriSP.trace("__IriSP.playerReady","API CALL "+__IriSP.player); |
849 //__IriSP.trace("__IriSP.playerReady","API CALL "+__IriSP.player); |
827 IriSP.MyApiPlayer.ready(IriSP.player); |
850 IriSP.MyApiPlayer.ready( IriSP.player ); |
828 //__IriSP.trace("__IriSP.playerReady","API CALL END "); |
851 //__IriSP.trace("__IriSP.playerReady","API CALL END "); |
829 |
852 |
830 var url = document.location.href; |
853 var url = document.location.href; |
831 var time = IriSP.retrieveTimeFragment(url); |
854 var time = IriSP.retrieveTimeFragment( url ); |
832 //__IriSP.trace("__IriSP.playerReady"," "+url+" "+time ); |
855 //__IriSP.trace("__IriSP.playerReady"," "+url+" "+time ); |
833 IriSP.startPosition = time; |
856 IriSP.startPosition = time; |
834 //__IriSP.trace("__IriSP.playerReady"," LISTENER LAUCHER"); |
857 //__IriSP.trace("__IriSP.playerReady"," LISTENER LAUCHER"); |
835 IriSP.addListeners(); |
858 IriSP.addListeners(); |
836 //__IriSP.trace("__IriSP.playerReady"," LISTENER END"); |
859 //__IriSP.trace("__IriSP.playerReady"," LISTENER END"); |
837 |
860 |
838 } |
861 }; |
|
862 |
839 IriSP.addListeners = function () { |
863 IriSP.addListeners = function () { |
840 if (IriSP.player) { |
864 if ( IriSP.player ) { |
841 IriSP.trace("__IriSP.addListeners","ADD Listener "); |
865 IriSP.trace("__IriSP.addListeners","ADD Listener "); |
842 IriSP.player.addModelListener("TIME", "__IriSP.positionListener"); |
866 IriSP.player.addModelListener( "TIME", "__IriSP.positionListener"); |
843 IriSP.player.addControllerListener("VOLUME", "__IriSP.volumeListener"); |
867 IriSP.player.addControllerListener( "VOLUME", "__IriSP.volumeListener" ); |
844 IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
868 IriSP.player.addModelListener( 'STATE', '__IriSP.stateMonitor' ); |
845 } else { |
869 } else { |
846 IriSP.setTimeout("__IriSP.addListeners()",100); |
870 IriSP.setTimeout( "__IriSP.addListeners()", 100 ); |
847 } |
871 } |
848 |
872 |
849 // et changer les boutons |
873 // et changer les boutons |
850 } |
874 }; |
851 IriSP.stateMonitor = function (obj) { |
875 |
852 |
876 IriSP.stateMonitor = function ( obj ) { |
853 if(obj.newstate == 'PAUSED') |
877 |
854 { |
878 if(obj.newstate == 'PAUSED') { |
855 IriSP.trace("__IriSP.stateMonitor","PAUSE"); |
879 IriSP.trace( "__IriSP.stateMonitor", "PAUSE" ); |
856 IriSP.MyApiPlayer.changePageUrlOffset(IriSP.currentPosition); |
880 IriSP.MyApiPlayer.changePageUrlOffset( IriSP.currentPosition ); |
857 IriSP.jQuery(".ui-icon-play").css("background-position","0px -160px"); |
881 IriSP.jQuery( ".ui-icon-play" ).css( "background-position","0px -160px" ); |
858 |
882 |
859 } else if (obj.newstate == 'PLAYING'){ |
883 } else if (obj.newstate == 'PLAYING' ){ |
860 |
884 |
861 IriSP.trace("__IriSP.stateMonitor","PLAYING "+IriSP.startPosition ); |
885 IriSP.trace( "__IriSP.stateMonitor", "PLAYING "+IriSP.startPosition ); |
862 |
886 |
863 // forcer le buffering mais stop du player si dans config |
887 // force buffering even if autostart is disabled. |
864 if (IriSP.config.player.flashvars.autostart=="false" && IriSP.firstplay==false && IriSP.startPosition == 0){ |
888 if ( IriSP.config.player.flashvars.autostart == "false" && IriSP.firstplay == false && IriSP.startPosition == 0 ) { |
865 IriSP.trace("__IriSP.stateMonitor","first stop ???"); |
889 IriSP.trace("__IriSP.stateMonitor","first stop ???"); |
866 IriSP.MyApiPlayer.play(); |
890 IriSP.MyApiPlayer.play(); |
867 IriSP.firstplay = true; |
891 IriSP.firstplay = true; |
868 IriSP.MyLdt.checkTime(1); |
892 IriSP.MyLdt.checkTime( 1 ); |
869 } |
893 } |
870 |
894 |
871 // une fois la video prete a lire la déplacer au bon timecode |
895 // once that the video is loaded, move it to the correct timecode |
872 if(IriSP.startPosition!=null){ |
896 if( IriSP.startPosition!=null ){ |
873 IriSP.MyApiPlayer.update(IriSP.startPosition); |
897 IriSP.MyApiPlayer.update( IriSP.startPosition ); |
874 IriSP.startPosition = null; |
898 IriSP.startPosition = null; |
875 } |
899 } |
876 |
900 |
877 |
901 |
878 IriSP.jQuery(".ui-icon-play").css("background-position","-16px -160px"); |
902 IriSP.jQuery( ".ui-icon-play" ).css( "background-position", "-16px -160px" ); |
879 } else if (obj.newstate == 'BUFFERING'){ |
903 } else if (obj.newstate == 'BUFFERING'){ |
880 IriSP.trace("__IriSP.stateMonitor","BUFFERING : "+IriSP.config.player.flashvars.autostart); |
904 IriSP.trace( "__IriSP.stateMonitor", "BUFFERING : "+IriSP.config.player.flashvars.autostart ); |
881 //changePageUrlOffset(currentPosition); |
905 //changePageUrlOffset(currentPosition); |
882 } |
906 } |
883 |
907 |
884 } |
908 }; |
|
909 |
885 IriSP.positionListener = function(obj) { |
910 IriSP.positionListener = function(obj) { |
886 //__IriSP.trace("__IriSP.positionListener",obj.position); |
911 //__IriSP.trace("__IriSP.positionListener",obj.position); |
887 IriSP.currentPosition = obj.position; |
912 IriSP.currentPosition = obj.position; |
888 var tmp = document.getElementById("posit"); |
913 var tmp = document.getElementById( "posit" ); |
889 if (tmp) { tmp.innerHTML = "position: " + IriSP.currentPosition; } |
914 if (tmp) { tmp.innerHTML = "position: " + IriSP.currentPosition; } |
890 IriSP.jQuery("#slider-range-min").slider("value", obj.position); |
915 IriSP.jQuery( "#slider-range-min" ).slider( "value", obj.position); |
891 IriSP.jQuery("#amount").val(obj.position+" s"); |
916 IriSP.jQuery( "#amount" ).val(obj.position+" s"); |
892 // afficher annotation |
917 // display annotation |
893 IriSP.MyLdt.checkTime(IriSP.currentPosition); |
918 IriSP.MyLdt.checkTime( IriSP.currentPosition ); |
894 |
919 |
895 } |
920 }; |
|
921 |
896 IriSP.volumeListener = function (obj) { |
922 IriSP.volumeListener = function (obj) { |
897 IriSP.currentVolume = obj.percentage; |
923 IriSP.currentVolume = obj.percentage; |
898 var tmp = document.getElementById("vol"); |
924 var tmp = document.getElementById("vol"); |
899 if (tmp) { tmp.innerHTML = "volume: " + IriSP.currentVolume; } |
925 if (tmp) { tmp.innerHTML = "volume: " + IriSP.currentVolume; } |
900 } |
926 }; |
901 |
927 |
902 |
928 |
903 /* API DAILYMOTION */ |
929 /* dailymotion api */ |
904 onDailymotionPlayerReady = function (playerid){ |
930 onDailymotionPlayerReady = function (playerid) { |
905 |
931 |
906 //alert(playerid); |
932 //alert(playerid); |
907 IriSP.player = document.getElementById(IriSP.config.player.attributes.id); |
933 IriSP.player = document.getElementById( IriSP.config.player.attributes.id ); |
908 IriSP.MyApiPlayer.ready(IriSP.player); |
934 IriSP.MyApiPlayer.ready( IriSP.player ); |
909 |
935 |
910 var url = document.location.href; |
936 var url = document.location.href; |
911 var time = IriSP.retrieveTimeFragment(url); |
937 var time = IriSP.retrieveTimeFragment( url ); |
912 IriSP.startPosition = time; |
938 IriSP.startPosition = time; |
913 IriSP.DailymotionAddListeners(); |
939 IriSP.DailymotionAddListeners(); |
914 |
940 |
915 IriSP.MyApiPlayer.ready(playerid); |
941 IriSP.MyApiPlayer.ready(playerid); |
916 } |
942 }; |
|
943 |
917 IriSP.DailymotionAddListeners = function () { |
944 IriSP.DailymotionAddListeners = function () { |
918 if (IriSP.player) { |
945 if ( IriSP.player ) { |
919 IriSP.trace("__IriSP.addListeners","ADD Listener "); |
946 IriSP.trace( "__IriSP.addListeners","ADD Listener " ); |
920 //__IriSP.player.addEventListener("onStateChange", "__IriSP.DailymotionPositionListener"); |
947 //__IriSP.player.addEventListener("onStateChange", "__IriSP.DailymotionPositionListener"); |
921 setTimeout("__IriSP.DailymotionPositionListener()",100); |
948 setTimeout( "__IriSP.DailymotionPositionListener()", 100); |
922 IriSP.DailymotionPositionListener(); |
949 IriSP.DailymotionPositionListener(); |
923 IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener"); |
950 IriSP.player.addModelListener( "VOLUME", "__IriSP.volumeListener" ); |
924 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
951 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
925 } else { |
952 } else { |
926 IriSP.setTimeout("__IriSP.DailymotionAddListeners()",100); |
953 IriSP.setTimeout( "__IriSP.DailymotionAddListeners()", 100); |
927 } |
954 } |
928 } |
955 }; |
|
956 |
929 IriSP.DailymotionPositionListener = function() { |
957 IriSP.DailymotionPositionListener = function() { |
930 |
958 |
931 IriSP.currentPosition = IriSP.player.getCurrentTime(); |
959 IriSP.currentPosition = IriSP.player.getCurrentTime(); |
932 //__IriSP.trace("__IriSP.DailymotionPositionListener",__IriSP.currentPosition); |
960 //__IriSP.trace("__IriSP.DailymotionPositionListener",__IriSP.currentPosition); |
933 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
961 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
934 |
962 |
935 IriSP.jQuery("#slider-range-min").slider("value",IriSP.currentPosition); |
963 IriSP.jQuery( "#slider-range-min" ).slider( "value" , IriSP.currentPosition); |
936 IriSP.jQuery("#amount").val(IriSP.currentPosition+" s"); |
964 IriSP.jQuery( "#amount" ).val( IriSP.currentPosition+" s" ); |
937 // afficher annotation |
965 // afficher annotation |
938 /*__IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
966 /*__IriSP.MyLdt.checkTime(__IriSP.currentPosition); |
939 */ |
967 */ |
940 |
968 |
941 setTimeout("__IriSP.DailymotionPositionListener()",10); |
969 setTimeout( "__IriSP.DailymotionPositionListener()", 10 ); |
942 } |
970 }; |
943 |
971 |
944 /* API YOUTUBE */ |
972 /* youtube api */ |
945 onYouTubePlayerReady= function (playerid){ |
973 onYouTubePlayerReady= function (playerid){ |
946 |
974 |
947 var url = document.location.href; |
975 var url = document.location.href; |
948 var time = IriSP.retrieveTimeFragment(url); |
976 var time = IriSP.retrieveTimeFragment( url ); |
949 IriSP.player = document.getElementById(IriSP.config.player.attributes.id); |
977 IriSP.player = document.getElementById( IriSP.config.player.attributes.id ); |
950 IriSP.startPosition = time; |
978 IriSP.startPosition = time; |
951 |
979 |
952 IriSP.MyApiPlayer.ready(IriSP.player); |
980 IriSP.MyApiPlayer.ready( IriSP.player ); |
953 |
981 |
954 IriSP.MyApiPlayer.seek(time); |
982 IriSP.MyApiPlayer.seek( time ); |
955 IriSP.MyApiPlayer.play(); |
983 IriSP.MyApiPlayer.play(); |
956 |
984 |
957 |
985 |
958 IriSP.YouTubeAddListeners(); |
986 IriSP.YouTubeAddListeners(); |
959 IriSP.trace("onYouTubePlayerReady=",time); |
987 IriSP.trace( "onYouTubePlayerReady=", time); |
960 //__IriSP.MyApiPlayer.ready(playerid); |
988 //__IriSP.MyApiPlayer.ready(playerid); |
961 } |
989 }; |
|
990 |
962 IriSP.YouTubeAddListeners = function () { |
991 IriSP.YouTubeAddListeners = function () { |
963 if (IriSP.player) { |
992 if ( IriSP.player ) { |
964 IriSP.trace("__IriSP.addListeners","ADD Listener "); |
993 IriSP.trace( "__IriSP.addListeners", "ADD Listener " ); |
965 IriSP.player.addEventListener("onStateChange", "__IriSP.YouTubeStateMonitor"); |
994 IriSP.player.addEventListener( "onStateChange", "__IriSP.YouTubeStateMonitor" ); |
966 setTimeout("__IriSP.YouTubePositionListener()",100); |
995 setTimeout( "__IriSP.YouTubePositionListener()", 100 ); |
967 IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener"); |
996 IriSP.player.addModelListener( "VOLUME", "__IriSP.volumeListener" ); |
968 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
997 //__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor'); |
969 } else { |
998 } else { |
970 IriSP.setTimeout("__IriSP.YouTubePositionListener()",100); |
999 } |
971 } |
1000 }; |
972 } |
1001 |
973 IriSP.YouTubePositionListener = function() { |
1002 IriSP.YouTubePositionListener = function() { |
974 |
1003 |
975 IriSP.currentPosition = IriSP.player.getCurrentTime(); |
1004 IriSP.currentPosition = IriSP.player.getCurrentTime(); |
976 //__IriSP.trace("__IriSP.YouTubePositionListener",__IriSP.currentPosition); |
1005 //__IriSP.trace("__IriSP.YouTubePositionListener",__IriSP.currentPosition); |
977 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
1006 //__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition); |
978 |
1007 |
979 IriSP.MyLdt.checkTime(IriSP.currentPosition); |
1008 IriSP.MyLdt.checkTime(IriSP.currentPosition); |
980 IriSP.jQuery("#slider-range-min").slider("value",IriSP.currentPosition); |
1009 IriSP.jQuery( "#slider-range-min" ).slider( "value", IriSP.currentPosition ); |
981 IriSP.jQuery("#amount").val(IriSP.currentPosition+" s"); |
1010 IriSP.jQuery( "#amount" ).val( IriSP.currentPosition+" s" ); |
982 // afficher annotation |
1011 // afficher annotation |
983 IriSP.MyLdt.checkTime(IriSP.currentPosition); |
1012 IriSP.MyLdt.checkTime( IriSP.currentPosition ); |
984 |
1013 |
985 |
1014 |
986 setTimeout("__IriSP.YouTubePositionListener()",10); |
1015 setTimeout( "__IriSP.YouTubePositionListener()", 10 ); |
987 } |
1016 }; |
|
1017 |
988 IriSP.YouTubeStateMonitor = function (obj) { |
1018 IriSP.YouTubeStateMonitor = function (obj) { |
989 IriSP.player.addModelListener('__IriSP.YouTubeStateMonitor ', newstate); |
1019 IriSP.player.addModelListener( '__IriSP.YouTubeStateMonitor ', newstate ); |
990 //alert(newstate+" "+obj.newstate); |
1020 //alert(newstate+" "+obj.newstate); |
991 if(newstate == '2') |
1021 if(newstate == '2') { |
992 { |
|
993 IriSP.trace("__IriSP.stateMonitor","PAUSE"); |
1022 IriSP.trace("__IriSP.stateMonitor","PAUSE"); |
994 IriSP.MyApiPlayer.changePageUrlOffset(IriSP.currentPosition); |
1023 IriSP.MyApiPlayer.changePageUrlOffset( IriSP.currentPosition ); |
995 |
1024 |
996 }else if (newstate == '1'){ |
1025 } else if (newstate == '1' || newstate == '1') { |
997 // une fois la video prete a lire la déplacer au bon timecode |
1026 // une fois la video prete a lire la déplacer au bon timecode |
998 if(IriSP.startPosition!=null){ |
1027 if( IriSP.startPosition!=null ) { |
999 IriSP.MyApiPlayer.update(IriSP.startPosition); |
1028 IriSP.MyApiPlayer.update( IriSP.startPosition ); |
1000 IriSP.startPosition = null; |
|
1001 } |
|
1002 } |
|
1003 else if (newstate == '-1'){ |
|
1004 // une fois la video prete a lire la déplacer au bon timecode |
|
1005 if(IriSP.startPosition!=null){ |
|
1006 IriSP.MyApiPlayer.update(IriSP.startPosition); |
|
1007 IriSP.startPosition = null; |
1029 IriSP.startPosition = null; |
1008 } |
1030 } |
1009 } else if (newstate == '3'){ |
1031 } else if (newstate == '3'){ |
1010 IriSP.trace("__IriSP.stateMonitor","BUFFERING : "); |
1032 IriSP.trace("__IriSP.stateMonitor","BUFFERING : "); |
1011 //changePageUrlOffset(currentPosition); |
1033 //changePageUrlOffset(currentPosition); |
1012 } |
1034 } |
1013 |
1035 |
1014 } |
1036 }; |
1015 |
1037 |
1016 |
1038 |
1017 |
1039 /* utils */ |
1018 /* UTIL */ |
|
1019 // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript |
1040 // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript |
|
1041 /* FIXME: maybe make it a little more robust */ |
1020 IriSP.stripHtml = function(s){ |
1042 IriSP.stripHtml = function(s){ |
1021 return s.replace(/\\&/g, '&').replace(/\\</g, '<').replace(/\\>/g, '>').replace(/\\t/g, ' ').replace(/\\n/g, '<br />').replace(/'/g, ''').replace(/"/g, '"'); |
1043 return s.replace(/\\&/g, '&').replace(/\\</g, '<').replace(/\\>/g, '>').replace(/\\t/g, ' ').replace(/\\n/g, '<br />').replace(/'/g, ''').replace(/"/g, '"'); |
1022 } |
1044 }; |
1023 // conversion de couleur Decimal vers HexaDecimal || 000 si fff |
1045 |
1024 IriSP.DEC_HEXA_COLOR = function (dec){ |
1046 // conversion de couleur Decimal vers HexaDecimal || 000 si fff |
|
1047 /* FIXME : move it somewhere else */ |
|
1048 IriSP.DEC_HEXA_COLOR = function (dec) { |
1025 var hexa='0123456789ABCDEF',hex=''; |
1049 var hexa='0123456789ABCDEF',hex=''; |
1026 var tmp; |
1050 var tmp; |
1027 while (dec>15){ |
1051 while (dec>15){ |
1028 tmp = dec-(Math.floor(dec/16))*16; |
1052 tmp = dec-(Math.floor(dec/16))*16; |
1029 hex = hexa.charAt(tmp)+hex; |
1053 hex = hexa.charAt(tmp)+hex; |
1030 dec = Math.floor(dec/16); |
1054 dec = Math.floor(dec/16); |
1031 } |
1055 } |
1032 hex = hexa.charAt(dec)+hex; |
1056 hex = hexa.charAt(dec)+hex; |
1033 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ } |
1057 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ } |
1034 return(hex); |
1058 return(hex); |
1035 } |
1059 }; |
1036 |
1060 |
1037 |
1061 |
1038 /* Search methodes */ |
1062 /* Search methods */ |
1039 IriSP.SearchOldValue=""; |
1063 IriSP.SearchOldValue=""; |
1040 IriSP.searchblockOpen=false; |
1064 IriSP.searchblockOpen=false; |
1041 IriSP.searchblock = function (){ |
1065 IriSP.searchblock = function () { |
1042 IriSP.trace("__IriSP.searchblock",IriSP.searchblockOpen); |
1066 IriSP.trace( "__IriSP.searchblock", IriSP.searchblockOpen ); |
1043 if (IriSP.searchblockOpen==false){ |
1067 |
1044 IriSP.jQuery(".ui-icon-search").css("background-position","-144px -112px"); |
1068 if ( IriSP.searchblockOpen == false ) { |
|
1069 IriSP.jQuery( ".ui-icon-search" ).css( "background-position", "-144px -112px" ); |
1045 //__IriSP.jQuery("#LdtSearch").animate({height:26},250); |
1070 //__IriSP.jQuery("#LdtSearch").animate({height:26},250); |
1046 IriSP.jQuery("#LdtSearch").show(250); |
1071 IriSP.jQuery("#LdtSearch").show(250); |
|
1072 /* FIXME : refactor this */ |
1047 IriSP.jQuery("#LdtSearchInput").css('background-color','#fff'); |
1073 IriSP.jQuery("#LdtSearchInput").css('background-color','#fff'); |
1048 IriSP.jQuery("#LdtSearchInput").focus(); |
1074 IriSP.jQuery("#LdtSearchInput").focus(); |
1049 IriSP.jQuery("#LdtSearchInput").attr('value',IriSP.SearchOldValue); |
1075 IriSP.jQuery("#LdtSearchInput").attr('value',IriSP.SearchOldValue); |
1050 IriSP.Search(IriSP.SearchOldValue); |
1076 IriSP.Search(IriSP.SearchOldValue); |
1051 IriSP.searchblockOpen=true; |
1077 IriSP.searchblockOpen = true; |
1052 } else { |
1078 } else { |
1053 IriSP.SearchOldValue = IriSP.jQuery("#LdtSearchInput").attr('value'); |
1079 IriSP.SearchOldValue = IriSP.jQuery("#LdtSearchInput").attr('value'); |
1054 IriSP.jQuery("#LdtSearchInput").attr('value',''); |
1080 IriSP.jQuery("#LdtSearchInput").attr('value',''); |
1055 IriSP.SearchClean(); |
1081 IriSP.SearchClean(); |
1056 IriSP.jQuery(".ui-icon-search").css("background-position","-160px -112px"); |
1082 IriSP.jQuery(".ui-icon-search").css("background-position","-160px -112px"); |
1057 //__IriSP.jQuery("#LdtSearch").animate({height:0},250); |
1083 //__IriSP.jQuery("#LdtSearch").animate({height:0},250); |
1058 IriSP.jQuery("#LdtSearch").hide(250); |
1084 IriSP.jQuery("#LdtSearch").hide(250); |
1059 IriSP.searchblockOpen=false; |
1085 IriSP.searchblockOpen = false; |
1060 } |
1086 } |
1061 } |
1087 }; |
1062 IriSP.Search = function (value){ |
1088 |
|
1089 IriSP.Search = function ( value ){ |
1063 |
1090 |
1064 annotations = IriSP.LDTligne.annotations; |
1091 annotations = IriSP.LDTligne.annotations; |
1065 |
1092 |
1066 IriSP.trace("__IriSP.Search",annotations.length+" "+value); |
1093 IriSP.trace("__IriSP.Search", annotations.length+" "+value); |
|
1094 /* FIXME : rename finded => found */ |
1067 var finded = 0; |
1095 var finded = 0; |
1068 var findmem = 0; |
1096 var findmem = 0; |
1069 var factor = 0; |
1097 var factor = 0; |
1070 IriSP.trace(value,value.length); |
1098 IriSP.trace(value,value.length); |
1071 var valueS = value.toLowerCase(); |
1099 var valueS = value.toLowerCase(); |
1072 IriSP.trace("__IriSP.Search",annotations.length+" "+valueS); |
1100 IriSP.trace("__IriSP.Search", annotations.length+" "+valueS); |
1073 if(valueS.length>=3){ |
1101 if(valueS.length>=3){ |
1074 |
1102 |
1075 for (var i=0; i < annotations.length; ++i){ |
1103 for (var i=0; i < annotations.length; ++i){ |
1076 annotation = annotations[i]; |
1104 annotation = annotations[i]; |
1077 |
1105 |
1119 IriSP.jQuery("#LdtSearchInput").css('background-color','#fff'); |
1147 IriSP.jQuery("#LdtSearchInput").css('background-color','#fff'); |
1120 } else { |
1148 } else { |
1121 IriSP.SearchClean(); |
1149 IriSP.SearchClean(); |
1122 IriSP.jQuery("#LdtSearchInput").css('background-color','#f6f6f6'); |
1150 IriSP.jQuery("#LdtSearchInput").css('background-color','#f6f6f6'); |
1123 } |
1151 } |
1124 } |
1152 }; |
1125 IriSP.SearchClean = function (){ |
1153 |
|
1154 IriSP.SearchClean = function (){ |
1126 annotations = IriSP.LDTligne.annotations; |
1155 annotations = IriSP.LDTligne.annotations; |
1127 |
1156 |
1128 for (var i=0; i < annotations.length; ++i){ |
1157 for (var i=0; i < annotations.length; ++i){ |
1129 annotation = annotations[i]; |
1158 annotation = annotations[i]; |
1130 IriSP.jQuery("#"+annotation.id).dequeue(); |
1159 IriSP.jQuery("#"+annotation.id).dequeue(); |
1131 IriSP.jQuery("#"+annotation.id).animate({height:0},100); |
1160 IriSP.jQuery("#"+annotation.id).animate({height:0},100); |
1132 IriSP.jQuery("#"+annotation.id).css('border','0px'); |
1161 IriSP.jQuery("#"+annotation.id).css('border','0px'); |
1133 IriSP.jQuery("#"+annotation.id).css('border-color','red'); |
1162 IriSP.jQuery("#"+annotation.id).css('border-color','red'); |
1134 IriSP.jQuery("#"+annotation.id).animate({opacity:0.3},100); |
1163 IriSP.jQuery("#"+annotation.id).animate({opacity:0.3},100); |
1135 } |
1164 } |
1136 } |
1165 }; |
1137 IriSP.SearchCleanString = function (value){ |
1166 |
|
1167 IriSP.SearchCleanString = function (value){ |
1138 var reg = new RegExp("(chien)", "g"); |
1168 var reg = new RegExp("(chien)", "g"); |
1139 value.replace(reg,"") |
1169 value.replace(reg,""); |
1140 return value; |
1170 return value; |
1141 } |
1171 }; |
1142 IriSP.SearchThisSegment = function (annotation){ |
1172 |
|
1173 IriSP.SearchThisSegment = function (annotation){ |
|
1174 /* FIXME: to implement */ |
1143 IriSP.jQuery("#LdtSearchInput").text(annotation.title); |
1175 IriSP.jQuery("#LdtSearchInput").text(annotation.title); |
1144 IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotation.title); |
1176 IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotation.title); |
1145 /*__IriSP.jQuery("#Ldt-SaDescription").text(annotationTempo.description); |
1177 /*__IriSP.jQuery("#Ldt-SaDescription").text(annotationTempo.description); |
1146 __IriSP.jQuery("#Ldt-SaKeywordText").html("Mots clefs : "+annotationTempo.htmlTags);*/ |
1178 __IriSP.jQuery("#Ldt-SaKeywordText").html("Mots clefs : "+annotationTempo.htmlTags);*/ |
1147 } |
1179 }; |
1148 |
1180 |
1149 |
1181 |
1150 /* CLASS Ligne (annotationType) */ |
1182 /* CLASS Ligne (annotationType) */ |
1151 |
1183 |
1152 IriSP.LDTligne = null; |
1184 IriSP.LDTligne = null; |
1153 __IriSP.Ligne = function (id,title,description,duration){ |
1185 __IriSP.Ligne = function( id, title, description, duration ) { |
1154 this.id = id; |
1186 this.id = id; |
1155 this.title = title; |
1187 this.title = title; |
1156 this.description = description; |
1188 this.description = description; |
1157 // |
1189 // |
1158 this.annotations = new Array(); |
1190 this.annotations = new Array(); |
1159 this.duration = duration; |
1191 this.duration = duration; |
1160 this.annotationOldRead=""; |
1192 this.annotationOldRead = ""; |
1161 IriSP.LDTligne = this; |
1193 IriSP.LDTligne = this; |
1162 IriSP.trace("__IriSP.Ligne","CREATE "+IriSP.LDTligne); |
1194 IriSP.trace("__IriSP.Ligne","CREATE "+IriSP.LDTligne); |
1163 } |
1195 }; |
1164 __IriSP.Ligne.prototype.addAnnotation = function (id,begin,end,media,title,description,color,tags){ |
1196 |
|
1197 __IriSP.Ligne.prototype.addAnnotation = function ( id, begin, end, media, title, description, color, tags ) { |
1165 var myAnnotation = new __IriSP.Annotation(id,begin,end,media,title,description,color,tags,this.duration); |
1198 var myAnnotation = new __IriSP.Annotation(id,begin,end,media,title,description,color,tags,this.duration); |
1166 this.annotations.push(myAnnotation); |
1199 this.annotations.push(myAnnotation); |
1167 //__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation ","add annotation "+title); |
1200 //__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation ","add annotation "+title); |
1168 } |
1201 }; |
1169 __IriSP.Ligne.prototype.onClickLigneAnnotation = function(id){ |
1202 |
|
1203 __IriSP.Ligne.prototype.onClickLigneAnnotation = function( id ) { |
|
1204 /* TODO implement */ |
1170 //changePageUrlOffset(currentPosition); |
1205 //changePageUrlOffset(currentPosition); |
1171 //player.sendEvent('SEEK', this.start); |
1206 //player.sendEvent('SEEK', this.start); |
1172 //__IriSP.trace("SEEK",this.start); |
1207 //__IriSP.trace("SEEK",this.start); |
1173 } |
1208 }; |
1174 __IriSP.Ligne.prototype.searchLigneAnnotation = function(id){ |
1209 |
|
1210 __IriSP.Ligne.prototype.searchLigneAnnotation = function( id ) { |
|
1211 /* TODO implement */ |
1175 /*for (){ |
1212 /*for (){ |
1176 }*/ |
1213 }*/ |
1177 } |
1214 }; |
1178 __IriSP.Ligne.prototype.listAnnotations = function(){ |
1215 |
1179 |
1216 __IriSP.Ligne.prototype.listAnnotations = function() { |
1180 } |
1217 /* TODO implement */ |
1181 __IriSP.Ligne.prototype.nextAnnotation = function (){ |
1218 }; |
|
1219 |
|
1220 __IriSP.Ligne.prototype.nextAnnotation = function () { |
|
1221 |
1182 var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1; |
1222 var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1; |
1183 var annotationCible = this.annotations[annotationCibleNumber]; |
1223 var annotationCible = this.annotations[annotationCibleNumber]; |
1184 |
1224 |
1185 if(annotationCibleNumber<this.annotations.length-1){ |
1225 if( annotationCibleNumber<this.annotations.length-1 ){ |
1186 annotationCible.begin |
1226 IriSP.player.sendEvent( 'SEEK', annotationCible.begin/1000 ); |
1187 IriSP.player .sendEvent('SEEK', annotationCible.begin/1000); |
1227 IriSP.trace( "LIGNE ", "| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000); |
1188 IriSP.trace("LIGNE ","| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000); |
1228 } else { |
1189 }else{ |
1229 IriSP.player.sendEvent( 'SEEK', this.annotations[0].begin/1000); |
1190 IriSP.player .sendEvent('SEEK', this.annotations[0].begin/1000); |
1230 } |
1191 } |
1231 |
1192 |
1232 }; |
1193 |
1233 |
1194 } |
|
1195 __IriSP.Ligne.prototype.numAnnotation = function (annotationCible){ |
1234 __IriSP.Ligne.prototype.numAnnotation = function (annotationCible){ |
1196 for (var i=0; i < this.annotations.length; ++i){ |
1235 for (var i=0; i < this.annotations.length; ++i){ |
1197 if(annotationCible == this.annotations[i]){ |
1236 if(annotationCible == this.annotations[i]){ |
1198 return i; |
1237 return i; |
1199 } |
1238 } |
1200 } |
1239 } |
1201 } |
1240 }; |
|
1241 |
1202 __IriSP.Ligne.prototype.checkTime = function(time){ |
1242 __IriSP.Ligne.prototype.checkTime = function(time){ |
1203 |
1243 |
1204 var annotationTempo = -1; |
1244 var annotationTempo = -1; |
1205 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",time); |
1245 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",time); |
1206 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",this.annotations.length); |
1246 //__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",this.annotations.length); |