Skip to main content
bluebeezle
Inspiring
June 18, 2019
Question

Accessing Premiere's API

  • June 18, 2019
  • 2 replies
  • 575 views

I apologize for the noob question, but I'm new to html and its relationship with javascript.

I have a premiere panel I'm working on, and have set some buttons to link up to functions in my javascript file using onClick. I've got it working to the point where the buttons can trigger a basic alert. But when I try to access Premiere objects, like "app.project", the script fails.

What am I doing wrong here?

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<script src="./jsx/RenameItems.js"></script>

<script src="./lib/CSInterface-4.0.0.js"></script>

<script>

function Replace() {

findAndReplace(document.getElementById('find').value, document.getElementById('replace').value);

}

function AddPrefixAndSuffix() {

addPrefixAndSuffix(document.getElementById('prefix').value, document.getElementById('suffix').value);

}

</script>

<style>

body {

font-size: 75%;

    color: #b1b1b1;

}

th, td {

    padding: 0px;

}

table {

    border-spacing: 10px 5px;

}

button {

    width: 100%;

}

</style>

<title>Rename Items</title>

</head>

<body bgcolor="#232323">

<div id="content">

<table>

<tr>

<th align="left">Prefix:</th>

<th><input type="text" id="prefix"></th>

</tr>

<tr>

<th align="left">Suffix:</th>

<th><input type="text" id="suffix"></th>

</tr>

<tr>

<th colspan="2"><button type="button" onClick="AddPrefixAndSuffix()">Add Prefix/Suffix</button></th>

</tr>

<tr>

<th align="left">Find:</th>

<th><input type="text" id="find"></th>

</tr>

<tr>

<th align="left">Replace:</th>

<th><input type="text" id="replace"></th>

</tr>

<tr>

<th colspan="2"><button type="button" onClick="Replace()">Replace</button></th>

</tr>

</table>

</div>

</body>

</html>

function findAndReplace($find, $replace)

{

alert($find + ' ' + $replace);

alert(String(app.project));

}

function addPrefixAndSuffix($prefix, $suffix)

{

alert($prefix + ' ' + $suffix);

}

This topic has been closed for replies.

2 replies

Ten A
Community Expert
Community Expert
June 19, 2019
Justin Taylor-Hyper Brew
Community Expert
Community Expert
June 18, 2019

Take some time analyzing how the PPRO Example panel works to see how CEP panels communicate to the host application. You can't make ExtendScript Host app calls like app.project directly, you need to pass the stringified call from Javascript through csInterface.evalScript() to access the ExtendScript layer like so:

var csInterface = new CSInterface();

csInterface.evalScript('alert(app.project.name)');