|
197 | 197 | this.forceLang = true; |
198 | 198 | } |
199 | 199 |
|
| 200 | + if ($(media).data('meta-type') !== undefined && $(media).data('meta-type') !== "") { |
| 201 | + this.metaType = $(media).data('meta-type'); |
| 202 | + } |
| 203 | + |
200 | 204 | if ($(media).data('meta-div') !== undefined && $(media).data('meta-div') !== "") { |
201 | 205 | this.metaDiv = $(media).data('meta-div'); |
202 | 206 | } |
|
4074 | 4078 | }; |
4075 | 4079 |
|
4076 | 4080 | AblePlayer.prototype.setupMetadata = function(track, cues) { |
4077 | | - // NOTE: Metadata is currently only supported if data-meta-div is provided |
4078 | | - // The player does not display metadata internally |
4079 | | - if (this.metaDiv) { |
4080 | | - if ($('#' + this.metaDiv)) { |
4081 | | - // container exists |
4082 | | - this.$metaDiv = $('#' + this.metaDiv); |
4083 | | - this.hasMeta = true; |
| 4081 | + if (this.metaType === 'text') { |
| 4082 | + // Metadata is only supported if data-meta-div is provided |
| 4083 | + // The player does not display metadata internally |
| 4084 | + if (this.metaDiv) { |
| 4085 | + if ($('#' + this.metaDiv)) { |
| 4086 | + // container exists |
| 4087 | + this.$metaDiv = $('#' + this.metaDiv); |
| 4088 | + this.hasMeta = true; |
| 4089 | + this.meta = cues; |
| 4090 | + } |
4084 | 4091 | } |
4085 | 4092 | } |
4086 | | - this.meta = cues; |
4087 | | - } |
| 4093 | + else if (this.metaType === 'selector') { |
| 4094 | + this.hasMeta = true; |
| 4095 | + this.visibleSelectors = []; |
| 4096 | + this.meta = cues; |
| 4097 | + } |
| 4098 | + }; |
4088 | 4099 |
|
4089 | 4100 | AblePlayer.prototype.loadTextObject = function(src) { |
4090 | 4101 |
|
|
7223 | 7234 | (function ($) { |
7224 | 7235 | AblePlayer.prototype.updateMeta = function (time) { |
7225 | 7236 | if (this.hasMeta) { |
7226 | | - this.$metaDiv.show(); |
7227 | | - this.showMeta(time || this.getElapsed()); |
| 7237 | + if (this.metaType === 'text') { |
| 7238 | + this.$metaDiv.show(); |
| 7239 | + this.showMeta(time || this.getElapsed()); |
| 7240 | + } |
| 7241 | + else { |
| 7242 | + this.showMeta(time || this.getElapsed()); |
| 7243 | + } |
7228 | 7244 | } |
7229 | 7245 | }; |
7230 | 7246 |
|
7231 | 7247 | AblePlayer.prototype.showMeta = function(now) { |
7232 | | - var m, thisMeta, cues; |
| 7248 | + var m, thisMeta, cues, cueText, cueLines, i, line; |
7233 | 7249 | if (this.meta.length >= 1) { |
7234 | 7250 | cues = this.meta; |
7235 | 7251 | } |
|
7242 | 7258 | break; |
7243 | 7259 | } |
7244 | 7260 | } |
7245 | | - if (typeof thisMeta !== 'undefined') { |
7246 | | - if (this.currentMeta !== thisMeta) { |
7247 | | - // it's time to load the new metadata cue into the container div |
7248 | | - this.$metaDiv.html(this.flattenCueForMeta(cues[thisMeta]).replace('\n', '<br>')); |
| 7261 | + if (typeof thisMeta !== 'undefined') { |
| 7262 | + if (this.currentMeta !== thisMeta) { |
| 7263 | + if (this.metaType === 'text') { |
| 7264 | + // it's time to load the new metadata cue into the container div |
| 7265 | + this.$metaDiv.html(this.flattenCueForMeta(cues[thisMeta]).replace('\n', '<br>')); |
| 7266 | + } |
| 7267 | + else if (this.metaType === 'selector') { |
| 7268 | + // it's time to show content referenced by the designated selector(s) |
| 7269 | + cueText = this.flattenCueForMeta(cues[thisMeta]); |
| 7270 | + cueLines = cueText.split('\n'); |
| 7271 | + for (i=0; i<cueLines.length; i++) { |
| 7272 | + line = $.trim(cueLines[i]); |
| 7273 | + if (line.toLowerCase() === 'pause') { |
| 7274 | + this.pauseMedia(); |
| 7275 | + } |
| 7276 | + else { |
| 7277 | + if ($(line).length) { |
| 7278 | + // selector exists |
| 7279 | + $(line).show(); |
| 7280 | + // add to array of visible selectors so it can be hidden at end time |
| 7281 | + this.visibleSelectors.push(line); |
| 7282 | + } |
| 7283 | + } |
| 7284 | + } |
| 7285 | + } |
7249 | 7286 | this.currentMeta = thisMeta; |
7250 | 7287 | } |
7251 | 7288 | } |
7252 | | - else { |
7253 | | - this.$metaDiv.html(''); |
| 7289 | + else { |
| 7290 | + if (typeof this.$metaDiv !== 'undefined') { |
| 7291 | + this.$metaDiv.html(''); |
| 7292 | + } |
| 7293 | + if (this.visibleSelectors.length) { |
| 7294 | + for (i=0; i<this.visibleSelectors.length; i++) { |
| 7295 | + $(this.visibleSelectors[i]).hide(); |
| 7296 | + } |
| 7297 | + // reset array |
| 7298 | + this.visibleSelectors = []; |
| 7299 | + } |
7254 | 7300 | this.currentMeta = -1; |
7255 | 7301 | } |
7256 | 7302 | }; |
|
0 commit comments