diff --git a/services/premiere-plugin/CSXS/manifest.xml b/services/premiere-plugin/CSXS/manifest.xml index 599a6ce..fd415c3 100644 --- a/services/premiere-plugin/CSXS/manifest.xml +++ b/services/premiere-plugin/CSXS/manifest.xml @@ -2,7 +2,7 @@ diff --git a/services/premiere-plugin/js/main.js b/services/premiere-plugin/js/main.js index 5e5d261..9187aa4 100644 --- a/services/premiere-plugin/js/main.js +++ b/services/premiere-plugin/js/main.js @@ -1964,6 +1964,17 @@ function importFileToPremiereProject(filePath) { return new Promise(function (resolve, reject) { var safePath = filePath.replace(/\\/g, '\\\\'); + // Premiere can deadlock on importFiles() if a hidden prompt appears + // (off-screen modal, etc.). The evalScript callback then never fires. + // Race the import against a 60s timeout so the user sees an error + // instead of a frozen spinner. + var done = false; + var timer = setTimeout(function () { + if (done) return; + done = true; + reject(new Error('ExtendScript importFiles() did not return within 60s — Premiere may have a hidden dialog')); + }, 60000); + var script = [ '(function() {', ' var result = { success: false, message: "" };', @@ -1977,7 +1988,7 @@ function importFileToPremiereProject(filePath) { ' result.message = "File not found: ' + safePath + '";', ' return JSON.stringify(result);', ' }', - ' app.project.importFiles(["' + safePath + '"]);', + ' app.project.importFiles(["' + safePath + '"], true);', ' result.success = true;', ' result.message = "Imported successfully";', ' } catch (e) {', @@ -1988,6 +1999,9 @@ function importFileToPremiereProject(filePath) { ].join('\n'); csInterface.evalScript(script, function (resultStr) { + if (done) return; + done = true; + clearTimeout(timer); try { var parsed = JSON.parse(resultStr); if (parsed.success) resolve(parsed); diff --git a/services/premiere-plugin/jsx/premiere.jsx b/services/premiere-plugin/jsx/premiere.jsx index 075cd1e..d3529da 100644 --- a/services/premiere-plugin/jsx/premiere.jsx +++ b/services/premiere-plugin/jsx/premiere.jsx @@ -37,7 +37,7 @@ function importFileToProject(filePath) { return JSON.stringify(result); } - app.project.importFiles([filePath]); + app.project.importFiles([filePath], true); result.success = true; result.message = "File imported successfully"; @@ -96,7 +96,7 @@ function insertClipToSequence(filePath, trackIndex) { return JSON.stringify(result); } - app.project.importFiles([filePath]); + app.project.importFiles([filePath], true); var file = new File(filePath); var fileName = file.displayName; @@ -596,7 +596,7 @@ function relinkClipToNewMedia(clipInstanceId, newMediaPath) { } // Import the new media file into the project - app.project.importFiles([newMediaPath]); + app.project.importFiles([newMediaPath], true); // Replace the clip source with the new project item var fileName = newFile.displayName; @@ -812,7 +812,7 @@ function replaceMediaPath(oldPath, newPath) { return JSON.stringify(result); } - app.project.importFiles([newPath]); + app.project.importFiles([newPath], true); var newName = oldFile.displayName; var rootBin = app.project.rootItem;