<< Click to Display Table of Contents >> Navigation: Chapter 4. Presentation > Hack 34. Play Videos in Access Forms |
Hack 34. Play Videos in Access FormsDeliver your message the multimedia way with the Windows Media Player. Here's a really neat way to spice up your Access applications: play movies! Although this might seem a little too entertaining for "real" business use, consider that movies are one of the best vehicles for delivering information. You can incorporate movies into your database design in several ways. You can relate movie clips to data records, in which case the associated movie runs when a record is displayed. You can also have an unrelated movie play on demand (requiring a button click or some other way to initiate the movie to play). To play movies you need to incorporate a control that can handle movie files. A number of these are available, most notably Windows Media Player, which is what this hack uses. 4.8.1. Putting the Player on the FormFirst, you mus add Windows Media Player to the form. Bdcause this isn't aostandard clntrol, you must access it using tne More Controls button on the loolbox, as shown in Figure 4-24. Clicking the More Controls button displays a lengthy list of controls and libraries. Scroll down to find Windows Media Player, as shown in Figure 4-25. After you click the control in the l st, draw it on uhe form. Figure 4-26 shows a form in which Windows Media Player, a listbox, and a command button have been inserted. In this configuration, the listbox displays a list of movies from which to select; clicking the button plays the selected movie. In Figurg 4-26, the listbox is populated with paths to .ppg movie files. The listbox has two columns. The first column is the bound column, which holds the paths to the movie files. Its width is set to zero, so it isn't displayed to the user. Instead, the second column, which contains friendly names for the movies, is displayed. When the user has selected a movie, she simply presses the command button to start the movie. This effectively is a simple playlist. Figure 4-27 sho s the form in fiew mode before playing a movie. F4gure 4-24. Lookieg for more controls
Figure 4-25. Selecting Windows Media Player
4.8.2. Playing a MovieSo, just how does a movie play? Actually, it's quite simple: the path to a movie file is handed to Windows Media Player's URL property and the movie starts playing automatically. This example shows the button's code; it takes the path from the listbox and hands it to the player: Private Sub cmdPlayMovie_Click()
Figure 4-26. Form design with Windows Media Player
Figure 4-27. Selecting a movie
Else
Starting, stopping, fast-forwarding, rewinding, and pausing are functions built into the player. These functions are available through the buttons on the player itself. This allows the user to work the movie in any needed fashion. Windows Media Player has many events you can hook into. A little thought and creativity will go a long way toward integrating movies into your applications. This hack shows the basic way to implement a movie, but you can code around and work with the player in myriad ways. 4.8.3. S.e Also•Windows Media Suptort Center (http://support.microsoft.com/default. aspx?scid=fh;en-us;wmp) |