81 _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format]; |
77 _metadataInfo.serializer = IriSP.serializers[_metadataInfo.format]; |
82 } |
78 } |
83 if (typeof _metadataInfo.url === "undefined" && typeof _metadataInfo.src !== "undefined") { |
79 if (typeof _metadataInfo.url === "undefined" && typeof _metadataInfo.src !== "undefined") { |
84 _metadataInfo.url = _metadataInfo.src; |
80 _metadataInfo.url = _metadataInfo.src; |
85 } |
81 } |
86 console.log(_metadataInfo); |
|
87 if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") { |
82 if (typeof _metadataInfo.url !== "undefined" && typeof _metadataInfo.serializer !== "undefined") { |
88 return this.sourceManager.remoteSource(_metadataInfo); |
83 return this.sourceManager.remoteSource(_metadataInfo); |
89 } else { |
84 } else { |
90 return this.sourceManager.newLocalSource(_metadataInfo); |
85 return this.sourceManager.newLocalSource(_metadataInfo); |
91 } |
86 } |
92 } |
87 } |
93 |
88 |
94 IriSP.Metadataplayer.prototype.onLibsLoaded = function() { |
89 IriSP.Metadataplayer.prototype.onLibsLoaded = function() { |
95 console.log("Libs Loaded"); |
|
96 this.videoData = this.loadMetadata(this.video_metadata); |
90 this.videoData = this.loadMetadata(this.video_metadata); |
97 console.log(this.videoData); |
|
98 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
91 this.$ = IriSP.jQuery('#' + this.config.gui.container); |
99 this.$.css({ |
92 this.$.css({ |
100 "width": this.config.gui.width, |
93 "width": this.config.gui.width, |
101 "clear": "both" |
94 "clear": "both" |
102 }); |
95 }); |
103 if (typeof this.config.gui.height !== "undefined") { |
96 if (typeof this.config.gui.height !== "undefined") { |
104 this.$.css("height", this.config.gui.height); |
97 this.$.css("height", this.config.gui.height); |
105 } |
98 } |
106 |
99 |
107 var _this = this; |
100 var _this = this; |
108 console.log("calling OnLoad"); |
|
109 this.videoData.onLoad(function() { |
101 this.videoData.onLoad(function() { |
110 _this.onVideoDataLoaded(); |
102 _this.onVideoDataLoaded(); |
111 }); |
103 }); |
112 } |
104 } |
113 |
105 |
114 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { |
106 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() { |
115 console.log("Video Data Loaded"); |
107 console.log("Video Data Loaded"); |
116 if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") { |
108 if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") { |
117 var _media = this.videoData.currentMedia; |
109 var _media = this.videoData.currentMedia; |
|
110 console.log(_media); |
118 if (typeof _media !== "undefined") { |
111 if (typeof _media !== "undefined") { |
119 config.player.video = _media.video; |
112 this.config.player.video = _media.video; |
120 if (typeof _media.streamer !== "undefined") { |
113 if (typeof _media.streamer !== "undefined") { |
121 config.player.streamer = _media.streamer; |
114 this.config.player.streamer = _media.streamer; |
122 config.player.video = _media.video.replace(_media.streamer,''); |
115 this.config.player.video = _media.video.replace(_media.streamer,''); |
123 } |
116 } |
124 } |
117 } |
125 |
118 |
126 } |
119 } |
127 this.configurePopcorn(config.player); |
120 this.configurePopcorn(); |
128 this.widgets = []; |
121 this.widgets = []; |
|
122 console.log("Now instantiating widgets"); |
129 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
123 for(var i = 0; i < this.config.gui.widgets.length; i++) { |
130 this.widgets.push(new IriSP.Widgets[_config.type](this, this.config.gui.widgets[i])); |
124 var _widget = this.config.gui.widgets[i]; |
|
125 if (typeof IriSP[_widget.type] !== "undefined") { |
|
126 this.widgets.push(new IriSP[_widget.type](this, _widget)); |
|
127 } else { |
|
128 console.log("Error, Call to Undefined Widget Type"); |
|
129 } |
131 }; |
130 }; |
132 this.$('.Ldt-loader').detach(); |
131 this.$.find('.Ldt-loader').detach(); |
133 } |
132 } |
134 |
133 |
135 IriSP.Metadataplayer.prototype.configurePopcorn = function() { |
134 IriSP.Metadataplayer.prototype.configurePopcorn = function() { |
136 var pop, |
135 var pop, |
137 ret = this.layoutDivs(), |
136 ret = this.layoutDivs("video"), |
138 containerDiv = ret[0], |
137 containerDiv = ret[0], |
139 spacerDiv = ret[1]; |
138 spacerDiv = ret[1]; |
140 |
139 |
141 /* insert one pixel of margin between the video and the first widget, |
140 /* insert one pixel of margin between the video and the first widget, |
142 * using the spacer. |
141 * using the spacer. |
143 */ |
142 */ |
144 IriSP.jQuery("#" + spacerDiv).css("height", Math.max(1, this.config.gui.spacer_div_height) + "px"); |
143 IriSP.jQuery("#" + spacerDiv).css("height", Math.max(1, this.config.gui.spacer_div_height) + "px"); |
145 |
144 |
146 switch(options.type) { |
145 console.log(this.config.player); |
|
146 |
|
147 switch(this.config.player.type) { |
147 /* |
148 /* |
148 todo : dynamically create the div/video tag which |
149 todo : dynamically create the div/video tag which |
149 will contain the video. |
150 will contain the video. |
150 */ |
151 */ |
151 case "html5": |
152 case "html5": |
152 var tmpId = Popcorn.guid("video"); |
153 var tmpId = Popcorn.guid("video"); |
153 IriSP.jQuery("#" + containerDiv).append("<video src='" + options.video + "' id='" + tmpId + "'></video>"); |
154 IriSP.jQuery("#" + containerDiv).append("<video src='" + this.config.player.video + "' id='" + tmpId + "'></video>"); |
154 |
155 |
155 if(options.hasOwnProperty("width")) |
156 if(options.hasOwnProperty("width")) |
156 IriSP.jQuery("#" + containerDiv).css("width", options.width); |
157 IriSP.jQuery("#" + containerDiv).css("width", this.config.player.width); |
157 |
158 |
158 if(options.hasOwnProperty("height")) |
159 if(options.hasOwnProperty("height")) |
159 IriSP.jQuery("#" + containerDiv).css("height", options.height); |
160 IriSP.jQuery("#" + containerDiv).css("height", this.config.player.height); |
160 pop = Popcorn("#" + tmpId); |
161 pop = Popcorn("#" + tmpId); |
161 break; |
162 break; |
162 |
163 |
163 case "jwplayer": |
164 case "jwplayer": |
164 var opts = IriSP.jQuery.extend({}, options); |
165 var opts = IriSP.jQuery.extend({}, this.config.player); |
165 delete opts.container; |
166 delete opts.container; |
166 delete opts.type; |
167 delete opts.type; |
167 opts.file = opts.video; |
168 opts.file = opts.video; |
168 delete opts.video; |
169 delete opts.video; |
169 |
170 |
170 if(!options.hasOwnProperty("flashplayer")) { |
171 if(!opts.hasOwnProperty("flashplayer")) { |
171 opts.flashplayer = IriSP.jwplayer_swf_path; |
172 opts.flashplayer = IriSP.jwplayer_swf_path; |
172 } |
173 } |
173 |
174 |
174 if(!options.hasOwnProperty("controlbar.position")) { |
175 if(!opts.hasOwnProperty("controlbar.position")) { |
175 opts["controlbar.position"] = "none"; |
176 opts["controlbar.position"] = "none"; |
176 } |
177 } |
177 pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); |
178 pop = new IriSP.PopcornReplacement.jwplayer("#" + containerDiv, opts); |
178 break; |
179 break; |
179 |
180 |
180 case "youtube": |
181 case "youtube": |
181 var opts = IriSP.jQuery.extend({}, options); |
182 var opts = IriSP.jQuery.extend({}, this.config.player); |
182 delete opts.container; |
183 delete opts.container; |
183 opts.controls = 0; |
184 opts.controls = 0; |
184 opts.autostart = false; |
185 opts.autostart = false; |
185 // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div. |
186 // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div. |
186 IriSP.jQuery("#" + containerDiv).css({ |
187 IriSP.jQuery("#" + containerDiv).css({ |