Microsoft Producer for PowerPoint 2003 SDK banner art
PreviousNext

Using Properties and Multiple Pages

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 sample illustrates how to create a custom user interface that uses HTML DIV elements to behave like separate pages. The code also specifies and retrieves two property values: one a default property, the other a custom property. Be sure to replace any URLs with your server address.

<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.                                **
**                                              **
**  This sample demonstrates handling properties**
**  using the Microsoft Producer object model   **
**  and using multiple pages in the custom HTML **
**  user interface.                             **
**************************************************
-->

<BODY onload = "OnLoad()">

<!-- Create a DIV for the first page. -->
<DIV ID = "page0" NAME = "page0">

This page prompts the user for two property values.<BR>
Copyright is a built-in property. Speaker is a custom property.<BR>
<BR>
Please provide copyright info and the speaker's name.<BR>
<BR>

<!-- These two TEXT elements retrieve the property values. -->
Copyright: <INPUT TYPE = "TEXT" ID = "Copyright" NAME = "Copyright">
Speaker: <INPUT TYPE = "TEXT" ID = "Speaker" NAME = "Speaker">


<BR><BR>
Click <B>Next</B> to review the publishing parameters.

</DIV>

<!-- Create a hidden DIV for the second page. -->
<DIV ID = "page1" NAME = "page1" STYLE = "DISPLAY: none">
 
Please provide a name for the presentation.<BR>
<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>
Click <B>Next</B> to publish the presentation.
<BR>
<BR>
<DIV ID = "Feedback" NAME = "Feedback" STYLE = "BACKGROUND: yellow"></DIV>

</DIV>


<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 = OnWizardNext;
   window.document.OnWizardBack = OnWizardBack;

   // Set the value of the Producer object to window.external 
   // to gain access to the Producer object model.
   Application = window.external;

   // Check whether the Producer version is compatible with this WebHost.
   var AppVersion = Application.Version;
   if (AppVersion.substring(0,3) != "2.0")
      alert ("Warning: Producer version doesn't match.");

   // Create a Profile Manager object.
   ProfileMgr = Application.ProfileManager;

   // Retrieve a Project.Properties object.
   ProjProp = Application.Project.Properties;

   // Retrieve a WebHost object that represents the current e-service.
   WebHost = ProjProp.PublishWebHost;
}


// This function executes when the user clicks Next in the Publish Wizard UI.
function OnWizardNext(){
   // Store the DIV elements in object variables.
   var page0 = document.all.item("page0");
   var page1 = document.all.item("page1");

   //Test whether the DIV is visible.
   if (page0.style.display == ""){

      // Store the property values the user entered.
      PersistPropertyValues();

      // Hide Page 0,.
      page0.style.display = "none";

      // Show Page 1.
      page1.style.display = "";

      // Display the parameter values in the DIV.
      Feedback.innerHTML += "Publish destination = " + PublishDestination + "<BR>";
      Feedback.innerHTML += "Playback location = " + PlaybackAddress + "<BR>";
      Feedback.innerHTML += "Profile = MediumQualityAudioVideo" + "<BR><BR>";
        
      // Display the property values in the DIV.
      Feedback.innerHTML += "Copyright: " + ProjProp.Copyright + "<BR>";
      Feedback.innerHTML += "Speaker: " + ProjProp.GetCustomProperty("Speaker");

      return;
   }

   else if (page1.style.display == ""){
      // Test whether the user has entered a name for the presentation.
      if (presName.value.length <= 0){
         alert("Please enter a presentation name.");
         return;
      }

      // Call the function that starts the publishing process.
      PublishMe();
   }
   return false;
}

// This function executes when the user clicks Back in the Publish Wizard UI.
function OnWizardBack(){

   // Store the DIV elements in object variables.
   var page0 = document.all.item("page0");
   var page1 = document.all.item("page1"); 

   // Test whether Page 0 is visible.
   if (page0.style.display == ""){

      // It's the first page; do nothing.
      return;
   }

   // Test whether Page 1 is visible.
   if (page1.style.display == ""){
      // Hide Page 0.
      Feedback.innerHTML = "";
      page1.style.display = "none";

      // Show Page 1.
      page0.style.display = "";

      return true;
   }
   return false;
}

function PersistPropertyValues(){

   // Test whether the user provided copyright information.
   if (Copyright.value){
      // Persist the copyright information the user provided.
      ProjProp.Copyright = Copyright.value;
   }
  
   // Create or set the custom property for the speaker name.
   ProjProp.SetCustomProperty("Speaker", Speaker.value);

   return;
}

// This function specifies the property values to publish the presentation.
function PublishMe(){

   // 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;

   // 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 finished.
         alert ("Publish complete.");

         // Close the Publish Wizard window.
         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.");
   
   }

   return;
}

// 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>
PreviousNext


© 2001-2003 Microsoft Corporation. All rights reserved.