# HG changeset patch # User hamidouk # Date 1323793899 -3600 # Node ID 8568e47379a24446db59a800272f72b70fbd46d3 # Parent 35495f156c4130a7382d4cf61712c76cca1a7c35 added autoconfiguration of the media source for rtmp streams. diff -r 35495f156c41 -r 8568e47379a2 src/js/data.js --- a/src/js/data.js Tue Dec 13 15:14:15 2011 +0100 +++ b/src/js/data.js Tue Dec 13 17:31:39 2011 +0100 @@ -37,7 +37,7 @@ /* automagically choose between json and jsonp */ if (url.indexOf(document.location.hostname) === -1 && - url[0] !== '/' /* not a relative url */ ) { + url.indexOf("http://") !== -1 /* not a relative url */ ) { // we contacting a foreign domain, use JSONP IriSP.jQuery.get(url, {}, IriSP.wrap(this, func), "jsonp"); diff -r 35495f156c41 -r 8568e47379a2 src/js/init.js --- a/src/js/init.js Tue Dec 13 15:14:15 2011 +0100 +++ b/src/js/init.js Tue Dec 13 17:31:39 2011 +0100 @@ -3,6 +3,13 @@ */ +IriSP.setupDataLoader = function() { + /* we set it up separately because we need to + get data at the very beginning, for instance when + setting up the video */ + IriSP.__dataloader = new IriSP.DataLoader(); +}; + IriSP.configurePopcorn = function (layoutManager, options) { var pop; var ret = layoutManager.createDiv(); @@ -29,6 +36,20 @@ case "jwplayer": var opts = IriSP.jQuery.extend({}, options); delete opts.container; + + /* exit if we can't access the metadata */ + if (typeof(IriSP.__jsonMetadata) === "undefined") { + break; + }; + + + // the json format is totally illogical + opts.streamer = IriSP.__jsonMetadata["medias"][0]["meta"]["item"]["value"]; + var source = IriSP.__jsonMetadata["medias"][0]["href"]; + + // the source if a full url but jwplayer wants an url relative to the + // streamer url, so we've got to remove the common part. + opts.file = source.slice(opts.streamer.length); pop = IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); break; @@ -53,10 +74,8 @@ }; IriSP.configureWidgets = function (popcornInstance, layoutManager, guiOptions) { - - var dt = new IriSP.DataLoader(); - var serialFactory = new IriSP.SerializerFactory(dt); - + + var serialFactory = new IriSP.SerializerFactory(IriSP.__dataloader); var params = {width: guiOptions.width, height: guiOptions.height}; var ret_widgets = []; diff -r 35495f156c41 -r 8568e47379a2 src/js/main.js --- a/src/js/main.js Tue Dec 13 15:14:15 2011 +0100 +++ b/src/js/main.js Tue Dec 13 17:31:39 2011 +0100 @@ -7,7 +7,7 @@ /* crap code will be the first against the wall when the revolution comes */ -IriSP.loadLibs = function( libs, customCssPath, callback ) { +IriSP.loadLibs = function( libs, customCssPath, metadata_url, callback ) { // Localize jQuery variable IriSP.jQuery = null; @@ -117,7 +117,14 @@ $( '.dynamic_css' ).clone().appendTo( 'head' ); } - callback(); + IriSP.setupDataLoader(); + IriSP.__dataloader.get(metadata_url, + function(data) { + /* save the data so that we could re-use it to + configure the video + */ + IriSP.__jsonMetadata = data; + callback.call(window) }); }); } }; diff -r 35495f156c41 -r 8568e47379a2 test/integration/polemic.htm --- a/test/integration/polemic.htm Tue Dec 13 15:14:15 2011 +0100 +++ b/test/integration/polemic.htm Tue Dec 13 17:31:39 2011 +0100 @@ -103,10 +103,6 @@ }, player:{ type:'jwplayer', // player type - container: 'PopcornContainer', - // the rest is player-dependent configuration options. - file : "video/ldtplatform/museologie_inaugurale_20111018_flat.f4v", - streamer: "rtmp://media.iri.centrepompidou.fr/ddc_player/", flashplayer : '../libs/player.swf', live: true, "controlbar.position" : "none", @@ -116,7 +112,7 @@ } }; - IriSP.loadLibs(IriSP.lib, config.gui.css, + IriSP.loadLibs(IriSP.lib, config.gui.css, "polemic_fr.json", function() { var layoutManager = new IriSP.LayoutManager(config.gui.container); var pop = IriSP.configurePopcorn(layoutManager, config.player);