Skip to content
This repository was archived by the owner on May 21, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 89 additions & 4 deletions PopcornEditor/src/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,95 @@ function init() {
resizeHandler.resize();
window.addEventListener( "resize", resizeHandler.resize );

function preprocess(json, callback) {
if (!json || !json.media || !config.savedDataUrl.startsWith('https://archive.org')) return callback(json);

var id = config.savedDataUrl.split('=').pop();
var url = "https://archive.org/download/" + id + "/" + id + ".mp4"
var thumb = "https://archive.org/download/" + id + "/format=Thumbnail";

jQuery.ajax({
type: "HEAD",
async: true,
url: url,
}).done(function(message, text, jqXHR) {
json.media[0].tracks = [{
"name": "",
"id": "0",
"order": 0,
"trackEvents": [
{
"id": "PPAP",
"type": "sequencer",
"popcornOptions": {
"source": [ url ],
"start": 0,
"end": json.media[0].duration,
"from": 0,
"duration": json.media[0].duration,
"target": "video-container",
"fallback": [ "" ],
"zindex": 997,
"id": "PPAP",
"width": 100,
"height": 100,
"top": 0,
"left": 0,
"volume": 100,
"hidden": false,
"mute": false,
"contentType": "",
"type": "",
"denied": false
},
"track": "0",
"name": "PPAP0"
}
]
}, {
"name": "",
"id": "1",
"order": 1,
"trackEvents": [
{
"id": "PPAP1",
"type": "image",
"popcornOptions": {
"start": 0,
"end": 0.2,
"target": "video-container",
"src": thumb,
"linkSrc": "",
"tags": "",
"photosetId": "",
"count": 3,
"width": 100,
"height": 100,
"top": 0,
"left": 0,
"innerTop": 0,
"innerLeft": 0,
"innerWidth": 0,
"innerHeight": 0,
"title": "",
"transition": "popcorn-fade",
"zindex": 990,
"id": "PPAP1"
},
"track": "1",
"name": "PPAP1"
}
]
}];
callback(json);
}).error(function(jqXHR, textStatus, errorThrown) {
callback(json);
});
}

// parse the savedDataUrl (to JSON) and then invoke the 2nd param (closure / anonymous function)
// with the parsed project JSON
Project.load( config.savedDataUrl, function( json ){
Project.load( config.savedDataUrl, function(json) { preprocess(json, function(json) {
Controls.create( "controls", {
onShareClick: function() {
shareClick( popcorn );
Expand Down Expand Up @@ -691,7 +776,7 @@ function init() {
embedInfo.parentNode.removeChild( embedInfo );
}

}); // end Project.load() call
})}); // end Project.load() call



Expand Down Expand Up @@ -754,15 +839,15 @@ function init() {

document.addEventListener( "DOMContentLoaded", function() {
// Source tree case vs. require-built case.

// if a user comes to http://archive.org/pop
// we need to auto-redirect them to https://archive.org/pop
// due to CORS issues, etc.
if ( location.href.match(/^http:\/\/(.*)archive.org\/pop\//) ){
location.href = location.href.replace(/^http:\/\//, 'https://');
return;
}

if ( typeof require === "undefined" ) {
var rscript = document.createElement( "script" );
rscript.onload = function() {
Expand Down