![]() |
Previous | Next |
If you write code that attempts to publish a Producer presentation by using a profile that is incompatible with the content on the Producer
You can write code to test whether a particular type of content exists on the Producer timeline. To determine if a video clip exists on the timeline, first create and initialize a variable to hold a Boolean value that represents whether content on the Producer timeline contains video:
var bHasVideo = Application.Project.TimelineHasVideo;
Having tested whether at least one video clip exists on the Producer timeline, you can use that information to determine which profiles are valid to use when publishing the presentation content. This process involves iterating through the list of profiles available in the Profile Manager and testing each one to determine its validity. The following code example determines which profiles are valid for the presentation and adds only the valid profile names as options to an HTML SELECT element named selProfiles. The code makes use of the variable bHasVideo from the previous example.
// Store the count of profiles contained in the Profile Manager.
var nCount = ProfileMgr.Count;
// Test whether the Profile Manager contains profiles.
if (!nCount > 0){
// No profiles, alert the user and exit the function.
alert("Error: No profiles available!");
return false;
}
// Iterate through the profiles in the Profile Manager collection.
for (var i = 0; i < nCount; i++){
// Retrieve the profile located at index i.
var Profile = ProfileMgr.Item(i);
// If the profile is incompatible with the content,
// don't add it to the selProfile SELECT element list.
if (!bHasVideo && Profile.IsVideoProfile)
continue;
if (bAudioOnly && Profile.IsAudioProfile)
continue;
// Always exclude the profiles that are not publish profiles.
if (!Profile.IsPublishProfile)
continue;
// Add the valid profile to the selProfile SELECT element.
var oOption = document.createElement("OPTION");
oOption.text = Profile.Name;
oOption.value = i;
selProfile.add(oOption);
}
For the complete sample code that accompanies this topic, see the topic Allowing the User to Select Profiles in the Samples section.
Previous | Next |