diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index 3fc35654..ccca4ead 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -733,6 +733,8 @@ Optional keys are: "autocomplete": Available if the layer is used as a filter "canAddAnnotations": Permissions per user level + "canPlayClips": If true, clips from this layer will play for users + with canPlayClips access "entity": ID of the referenced entity (if type is "entity") "hasEvents": If true, the calendar will be populated with matches from this layer @@ -768,6 +770,7 @@ "id": "subtitles", "title": "Subtitles", "canAddAnnotations": {"staff": true, "admin": true}, + "canPlayClips": true, "hasEvents": true, "hasPlaces": true, "isSubtitles": true, diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index b9faf6af..2d6f2bbb 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -752,6 +752,8 @@ Optional keys are: "autocomplete": Available if the layer is used as a filter "canAddAnnotations": Permissions per user level + "canPlayClips": If true, clips from this layer will play for users + with canPlayClips access "entity": ID of the referenced entity (if type is "entity") "hasEvents": If true, the calendar will be populated with matches from this layer @@ -778,6 +780,7 @@ "id": "notes", "title": "Notes", "canAddAnnotations": {"member": true, "researcher": true, "staff": true, "admin": true}, + "canPlayClips": true, "hasEvents": true, "hasPlaces": true, "item": "Note", @@ -789,6 +792,7 @@ "id": "subtitles", "title": "Subtitles", "canAddAnnotations": {"researcher": true, "staff": true, "admin": true}, + "canPlayClips": true, "hasEvents": true, "hasPlaces": true, "isSubtitles": true, diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index aba8a791..80727170 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -634,6 +634,8 @@ Optional keys are: "autocomplete": Available if the layer is used as a filter "canAddAnnotations": Permissions per user level + "canPlayClips": If true, clips from this layer will play for users + with canPlayClips access "entity": ID of the referenced entity (if type is "entity") "hasEvents": If true, the calendar will be populated with matches from this layer @@ -683,6 +685,7 @@ "id": "transcripts", "title": "Transcripts", "canAddAnnotations": {"member": true, "staff": true, "admin": true}, + "canPlayClips": true, "isSubtitles": true, "item": "Transcript", "showInfo": true, diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index 3c61222e..4bc20c76 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -573,6 +573,8 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution. Optional keys are: "autocomplete": Available if the layer is used as a filter "canAddAnnotations": Permissions per user level + "canPlayClips": If true, clips from this layer will play for users + with canPlayClips access "entity": ID of the referenced entity (if type is "entity") "hasEvents": If true, the calendar will be populated with matches from this layer @@ -616,6 +618,7 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution. "id": "subtitles", "title": "Subtitles", "canAddAnnotations": {"staff": true, "admin": true}, + "canPlayClips": true, "hasEvents": true, "hasPlaces": true, "isSubtitles": true, diff --git a/static/js/utils.js b/static/js/utils.js index 1ab79c68..2f546441 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -1948,6 +1948,54 @@ pandora.getVideoURL = function(id, resolution, part, track) { + pandora.getVideoURLName(id, resolution, part, track); }; +pandora.getCensoredClips = function(data) { + var annotations = [], + clips = [], + last; + pandora.site.layers.filter(function(layer) { + return layer.canPlayClips; + }).forEach(function(layer) { + data.layers[layer.id] && data.layers[layer.id].forEach(function(annotation, i) { + annotations.push(annotation) + }); + }); + if (annotations.length) { + Ox.sort(annotations, function(clip) { + return clip['in']; + }).forEach(function(clip) { + if (last && last['out'] >= clip['in']) { + last['out'] = Math.max(last['out'], clip['out']); + } else { + last = { + 'in': clip['in'], + out: clip.out + }; + clips.push(last); + } + }); + } + return clips.length + ? clips.map(function(clip, i) { + return { + 'in': i == 0 ? 0 + : clips[i - 1].out, + out: clip['in'] + }; + }).concat([{ + 'in': Ox.last(clips).out, + out: data.duration + }]).filter(function(censored) { + // don't include gaps shorter than one second + return censored.out - censored['in'] >= 1; + }) + : Ox.range(0, data.duration - 5, 60).map(function(position) { + return { + 'in': position + 5, + out: Math.min(position + 60, data.duration) + }; + }); +}; + pandora.getVideoOptions = function(data) { var canPlayClips = data.editable || pandora.site.capabilities.canPlayClips[pandora.user.level] @@ -1958,29 +2006,8 @@ pandora.getVideoOptions = function(data) { options = {}; options.subtitlesLayer = pandora.getSubtitlesLayer(); options.censored = canPlayVideo ? [] - : canPlayClips ? ( - options.subtitlesLayer && data.layers[options.subtitlesLayer].length - ? data.layers[options.subtitlesLayer].map(function(subtitle, i) { - return { - 'in': i == 0 ? 0 - : data.layers[options.subtitlesLayer][i - 1].out, - out: subtitle['in'] - }; - }).concat([{ - 'in': Ox.last(data.layers[options.subtitlesLayer]).out, - out: data.duration - }]).filter(function(censored) { - // don't include gaps shorter than one second - return censored.out - censored['in'] >= 1; - }) - : Ox.range(0, data.duration - 5, 60).map(function(position) { - return { - 'in': position + 5, - out: Math.min(position + 60, data.duration) - }; - }) - ) - : [{'in': 0, out: data.duration}]; + : canPlayClips ? pandora.getCensoredClips(data) + : [{'in': 0, out: data.duration}]; options.video = []; pandora.site.video.resolutions.forEach(function(resolution) { if (data.audioTracks) {