A Complete Simple E-service
The following sample code creates a Web page that is displayed in the hosted browser window that is the custom user interface in the Microsoft Producer Publish Wizard. This is the page that is specified in Options.AddWebHost or by changing the HTMLBasedUIURL WebHost subkey in the registry. Be sure to replace any URLs with your server address and path.
<HTML>
<!--
**************************************************
** This is a sample of a custom user interface **
** HTML document. This sample requires that **
** content exists on the video timeline. If no **
** content can be encoded as video, an error **
** will result. You can change the profile to **
** one of the audio-only profile types when **
** appropriate. **
**************************************************
-->
<BODY onload = "OnLoad()">
This page allows the user to publish the presentation.<BR>
All the values are supplied in script, except <BR>
the name of the presentation, which is supplied<BR>
by the user.<BR>
The presentation must contain content on the video timeline<BR>
or an error will result. <BR>
<BR>
<!-- This is the TEXT INPUT element that retrieves the name
of the presentation from the user. -->
Presentation name:
<INPUT TYPE = "TEXT" ID = "presName" NAME = "presName">
<BR>
<BR>
<INPUT TYPE = "BUTTON" VALUE = "List Files to be Published"
onClick = "Application.Publisher.ShowManifest()">
<BR>
<BR>
Click<B> Next </B>to publish the presentation.
<BR>
<BR>
Publish Destination: http://MyServer/MyPath <BR>
Playback Location: http://MyServer/MyPath <BR>
Profile: MediumQualityAudioVideo
<SCRIPT language = "JScript">
// Global variables that correspond to WebHost properties.
var Application;
var WebHost;
var ProfileMgr;
var PublishDestination = "http://MyServer/MyPath";
var PlaybackAddress = "http://MyServer/MyPath";
// This function executes automatically when Producer loads the page.
function OnLoad(){
// Create the functions to handle the Next and Back button events
// in the Publish Wizard.
window.document.OnWizardNext = MyOnWizardNext;
window.document.OnWizardBack = MyOnWizardBack;
// Set the value of the Producer object to window.external
// to gain access to the Producer object model.
Application = window.external;
// Test whether the Producer version is compatible with the WebHost.
var AppVersion = Application.Version;
if (AppVersion.substring(0,3) != "2.0")
alert ("Warning: Producer version doesn't match.");
// Retrieve a WebHost object that represents the current e-service.
WebHost = Application.Project.Properties.PublishWebHost;
// Create a Profile Manager object.
ProfileMgr = Application.ProfileManager;
}
// This function executes when the user clicks Next in the Publish Wizard UI.
function MyOnWizardNext(){
// Test whether the user has entered a name for the presentation.
if (presName.value.length <= 0){
alert("Please enter a presentation name.");
return true;
}
// Set the profile to one of the Producer built-in profiles.
// Change this profile if necessary for your content.
var myProfile = ProfileMgr.MediumQualityAudioVideo;
WebHost.AddProfile(myProfile);
// Set the presentation name.
Application.Project.Properties.PublishName = presName.value;
// Set the presentation publish destination.
WebHost.PublishDestination = PublishDestination;
// Set the playback location.
WebHost.PlaybackAddress = PlaybackAddress;
// Call the function that begins the publishing process.
PublishMe();
return;
}
// This function executes when the user clicks the Back button in the Publish Wizard UI.
function MyOnWizardBack(){
// Return to the first page of the Publish Wizard.
return false;
}
// This function starts the publishing process.
function PublishMe(){
// Use try/catch error handling to verify publish validation.
try{
// Verify that a presentation doesn't exist with the same name.
var bDoesNotExist = Application.Publisher.ValidatePublishPresentation();
// Test whether ValidatePublishPresentation was successful.
if (bDoesNotExist == true){
// Publish the presentation.
Application.Publisher.PublishPresentation()
// Tell the user it is done.
alert("Publish complete.");
// Close the wizard.
ClosePubWiz();
}
else{
// Tell the user the there is a problem.
alert ("Cannot publish because the name exists.")
}
}
catch(e){
// Show an error message.
alert ("There were errors. Publish failed.");
}
}
// This function closes the Publish Wizard.
function ClosePubWiz(){
// Get a window object that represents the Publish Wizard.
var WizardWin = Application.Windows.FindByName("PublishWizard");
// Close the Publish Wizard.
Application.Windows(WizardWin).Close();
}
</SCRIPT>
</BODY>
</HTML>
For more information about this sample, see the topic in the Programming Guide section.
© 2001-2003 Microsoft Corporation. All rights reserved.