Multimedia
In this world of high-tech movies and video games, multimedia in business presentations is almost expected. Multimedia has the power to enhance a presentation, making it more interesting to watch and easier for the viewer to retain what was presented. However, there s a fine line between "very interesting" and "very distracting" again, we listen to the maxim "less is more."
While you are developing automated presentations, be sure that your program can handle scaling to the wide variety of hardware available for presentations. Even today, not all computers have good sound systems (or speakers that are decent enough to project to the whole room full of attendees), high-powered graphics cards, and lots of RAM and processor to allow the presentation to be successful. Ensure that your users have an alternative to awesome multimedia displays if the presentation computer can t handle multimedia, the "incredibly awesome" presentation quickly is perceived as "incredibly awful."
Sounding off
Sounds are managed through the SoundEffect object. The ActionSettings, AnimationSettings, and SlideShowTransition objects (discussed earlier in this chapter) each have a SoundEffect property to access the SoundEffect object.
There are a number of sound effects available in PowerPoint without using separate sound files. These built-in sounds are accessed using the names shown in any of the PowerPoint sound effect dropdown boxes. Figure 9 shows the Play sound dropdown on the Action Settings dialog.
Figure 9
. PowerPoint s Action Settings dialog, showing the built-in sound effects.Set the Name property to the text string corresponding to the sound you wish to use. This is an exception to the long list of numeric constants usually used by VBA! The list of options are: Applause, Breaking Glass, Camera, Cash Register, Chime, Clapping, Drive By, Drum Roll, Explosion, Gun Shot, Laser, Ricochet, Screeching Brakes, Slide Projector, Typewriter, and Whoosh.
#DEFINE ppMouseClick 1
oShape.ActionSettings[ppMouseClick].SoundEffect.Name = "Slide Projector"
Setting the Name property automatically sets the Type property to ppSoundFile (2). To turn off the sound, set the Type property to ppSoundNone (0). The constant ppStopPrevious (1) stops any sound currently being played.
To specify a WAV file to play, use the ImportFromFile method to both link to the WAV file and set the object to play it. Pass the fully qualified WAV filename. Once you have imported the WAV file, it is added to the list of sounds available so it can be referenced by other objects (by its filename without the path), just like the built-in sounds. The following lines of code import the WAV file, set the shape to play it when clicked, and then use the imported file by its name to set the same sound to play on the slide show transition.
#DEFINE ppMouseClick 1
SoundFile = GETENV("WINDIR") + "\Media\Chord.WAV"
oShape.ActionSettings[ppMouseClick].SoundEffect.ImportFromFile(SoundFile)
oSlide.SlideShowTransition.SoundEffect.Name = "CHORD.WAV"
The SoundEffect object has a Play method, which plays the sound on demand. Use the Play method only when you want the sound to play while your code is running; the use of the Play method does not affect whether sounds play in the slide show. It plays the sound set for the specified object:
oSlide.SlideShowTransition.SoundEffect.Play()
This line plays whatever sound is set in the slide s SlideShowTransition object.
Motion
To add video clips, you use the Shapes collection s AddMediaObject method. As Chapter 10, "PowerPoint Basics," points out, while AutoLayouts exist with placeholders for OLE objects, they cannot be used with Automation or macros.
The AddMediaObject method takes up to five parameters. The first is the filename, and is not optional. Next are the Left and Top. These are optional; the default is zero for both. The last two, Width and Height, are also optional, and default to the width and height of the object. The following line of code shows how to add one of FoxPro s sample AVI files (it is a spinning globe, not a fox, as the name seems to indicate).
oShape = oSlide.Shapes.AddMediaObject( ;
_SAMPLES + "Solution\Forms\Fox.AVI", 240, 156)
This adds the AVI file roughly centered in the slide.
There wasn t any magic involved in finding the Left and Top parameters. It was done interactively. Using the FoxPro Command Window, we opened an instance of PowerPoint and added a new presentation with a blank slide. Then we issued the preceding command, leaving out the Left and Top parameters, which placed the image in the upper left corner. Activating PowerPoint, we moved the image using the mouse to the location we wanted. Back in FoxPro s Command Window, we asked PowerPoint for the Top and Left properties, and typed the results into our code:
? oShape.Left
? oShape.Top
It s important to remember to let the tools do the work for you. FoxPro s object references persist until the variable is released, or the object in PowerPoint is unavailable (whether the presentation is closed or the object itself is deleted). Setting a reference to an object in FoxPro, switching to PowerPoint to interactively manipulate the PowerPoint objects, then querying the properties from FoxPro is a very powerful way to quickly determine the desired properties of the PowerPoint objects.
Adding the media clip with AddMediaObject sets it to play when the user clicks on it during the presentation. The AnimationSettings and ActionSettings objects change the behavior, setting it to play when the slide is selected, to continuously play while the slide is viewed, or to play when the mouse is moved over it. The ActionSettings object, which pertains to mouse clicks and movement, has no additional properties for multimedia (see the section "Taking action" earlier in this chapter). The AnimationSettings object, however, does have a number of properties relating to multimedia.
Figure 10 shows the Custom Animation dialog box, with the Multimedia Settings tab selected. This tab sets the properties of the AnimationSettings PlaySettings object. The PlaySettings object contains a number of properties that determine how the media clip plays during a slideshow. The check box labeled "Play using animation order" corresponds to the logical PlayOnEntry property. When PlayOnEntry is true, it plays the media clip when the slide is displayed (based on the AnimationSettings object s AnimationOrder property). PlayOnEntry also respects the other AnimationSettings properties, such as AdvanceMode and AdvanceTime if other objects that are higher in the order need mouse clicks to animate, then those lower in the order aren t animated until the mouse clicks force the preceding animations to happen. Set PlayOnEntry to false to ensure that the user must animate it manually.
The two radio buttons that set the "While playing" action correspond to the PauseAnimation property. When set to true (when the radio button reads "Pause slide show"), other automatic features of the slide show wait until the video clip has finished playing. When set to false, the other automatic features are played at the same time. This can be useful if you want several animated GIFs to play simultaneously. Set PauseAnimation to true when you only have one object to play, and do not want the slide show to advance before the object completes its play.
On the Custom Animation dialog, the Multimedia Settings tab has a "More Options" button, which corresponds to more animation properties. The check boxes correspond to the LoopUntilStopped and RewindMovie properties. To loop the animation until the user selects another action (or another action is automatically scheduled to run), set the LoopUntilStopped property to true. Setting it to false runs it once. The RewindMovie property controls whether the movie returns the view to the first frame when finished (true) or whether the movie stays on the last frame (false).
Figure 10
. Multimedia Custom Animation settings. The Multimedia Settings tab shows the properties that are available to media clips.A common scenario is to play the video continuously when the slide is selected. The following code adds the video clip object and sets the appropriate properties:
oShape = oSlide.Shapes.AddMediaObject( ;
_SAMPLES + "\Solution\Forms\Fox.AVI", 240, 156)
WITH oShape.AnimationSettings.PlaySettings
.PlayOnEntry = .T.
.LoopUntilStopped = .T.
ENDWITH
Many properties, such as PlayOnEntry, can be set with a logical value (.T. or .F.) or a numeric value (1 or -1). However, when you read them, they will always be numeric. This is a "feature" of how FoxPro s logical values are translated to a numeric property; the native numeric value will always be returned.
Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved