I’m trying to automate creating events in bulk via script. I have all necessary assets imported and verified uncorrupted files, but for some reason I’m getting the following errors when trying to associate files (all .OGGs) with the created events’ tracks: “Relationship ‘audioFile’ expects a destination of entity type ‘AudioFile’”
Is there a way to cast resulting object from studio.project.workspace.masterAssetFolder.getAsset() to an AudioFile? If not, is there another function I should be using to access audio assets? The documentation is not clear on best practice/any approach here.
Relevant code snippet:
var asset =studio.project.workspace.masterAssetFolder.getAsset("/VOX/"+rowData[1]+".ogg");
if(asset!=null){
//This results in missed files, but allows execution to continue. if(asset.isOfExactType('AudioFile')){
console.log("Found asset: "+rowData[1]+".ogg, "+typeof asset);//asset type output as 'object' regardless of if an AudioFile or not
var track = event.addGroupTrack();
var sound = track.addSound(event.timeline, "SingleSound", 0, 10);
sound.relationships.audioFile.add(asset);
sound.length = asset.length;
//}