Accessing sound files on a page and assigning them to play
I am trying to programmatically assign a large number of sound files (several hundred) to objects to play in an EPUB using InDesign 13.1.
I cannot understand how to access and assign the sound file after it has been placed on a page. I need to be able to assign it to my button with a soundBehaviors action, but I cannot find how to tell my button what sound file to use on the page.
=================================================================================
var myDocument = app.documents.add();
var myPage = myDocument.pages.item(0);
// build a loop and import 12 sound files on the page. They all appear in the Links panel. They will not be seen, just placed on the page to be accessed by different //buttons
for(var i = 1; i < 13; i++){
var fileString = "DISK:Users:PATH TO FILES:"Sound File " + i + ".mp3";
myPage.place(File(fileString));
}
// now create buttons and the actions to play the sound on click and link up to the sound files just placed on the page
for(var i = 1; i < 13; i++){
//make a button
var MyButton = myPage.buttons.add();
MyButton.properties = {
geometricBounds: [8,8,12,12],
strokeColor: "Black",
strokeWeight: 1,
name: "Example " + i
}
//here is where the sound gets linked to the button to play on a mouse down.
var mySoundStartBehavior = MyButton.soundBehaviors.add(
{
behaviorEvent: BehaviorEvents.MOUSE_DOWN,
operation: PlayOperations.PLAY,
abel: "Example!!",
// THIS is the issue - I have tried every way I can think of to access the sounds on the page and assign it and no luck.
soundItem: Page.sounds? sounds.items? a string to the sound file name? A link to the file on disk?
}
);
=======================================================
How do you get access to the sounds that have been successfully placed at the beginning of the script?
The object model docs makes it seem like page.sounds[0] should work, but it doesn't.