
The differences between analog and digital video are similar to the audio differences. An analog video is a series of squiggles that modulate an electron beam in a picture tube to paint images similar to what we see on a television.
Digitizing video freezes images into individual frames, each one a picture that can be manipulated. The frame rate is akin to the sample rate in that it explains how many times per second a video is frozen. Frame rates generally vary from 12 (animation) to 24 (film) and up. Instead of bandwidth, a video's frame rate affects how smooth the motion of objects within the video image will appear.
Video resolution defines how much information is used to describe each dot or pixel of a frame. It ranges from 8 (multimedia) to 24 (higher-end graphics).
To visualize what a digital video player device does, compare it to a VCR. Anything you can do with a VCR you can do with a digital video player device.
A digital video player device supports functions that manipulate digital video and audio files as well as digital video-only files. The audio-visual files have the extension of .avi (AVI means audio-visual interface).
The digital video device class, IMMDigitalVideo, includes functions that change the state of the window, query and set a device's playback speed, and change a video window's attributes. The video window is where the actual video is displayed. The window can be free-floating or in a canvas window along with the buttons to manipulate the video. This class inherits functions, such as playback, record, query, adjust speed of motion video, and modify the audio attributes of the audio stored in the video file. A sound card is required to play back the sound part of the video files.
The system-provided default video window does not provide a Close menu choice. If you want that capability, the digital video class provides the ability to replace the default video window with one of your choosing.
The command to create a digital video device object is as follows:
#include// Define the header file IMMDigitalVideo videoPlayer; // Define the object videoPlayer(true) // Pass true to the device constructors so // the devices are opened and no additional // functions calls are made before using // the device.
The type of system in which you plan to play your video files is relative to the type of performance you will get when you play your files. The AVI files that store the clips can be rather large, even for a brief commercial. We recommend that you use the loadOnThread function when reading in large video clips. If you use load, it will more than likely tie up your windowing system until the file is loaded. That can annoy your users. The loadOnThread function creates a thread to do the loading, which allows a user to continue doing another task.
In addition to requiring a lot of storage, playing video files requires fast computers. A 66-megahertz, 486 system is a minimum requirement. Lesser hardware produces less realistic videos with poorer resolution. Larger objects require more processor resources to animate. This means that it takes longer to move each frame of the animation from your hard drive, or wherever it resides, to your screen.
To sum up, factors affecting playback of a video are:
When a motion video device element is opened, the current position in the medium is the first playable area after any header or table of contents information.
Each frame in a motion video file has a number associated with it. The first frame is frame 0, the second frame is frame 1, and so on. The current position always indicates the frame that is about to be displayed. You can specify the play-from and play-to positions. You also give a frame position parameter to the seek command.
AVI files typically have digitized sound tracks along with their pictures. If you play the AVI file on a system with a sound card installed and turn on your speakers, you also hear the sound it contains.
The faster the machine, the faster the data processing and the playback are. Digital video is processor-intensive. Raw video requires huge amounts of memory--typically 900 kilobytes for a single frame of video, which equates to roughly 27 megabytes-per-second to record or play in real time. So, digital video is often data-compressed to make it manageable. The simplest form of video compression is a smaller frame size or slower frame rate. This is the reason most digital video used in multimedia is so small and jerky. With the slow data transfer rate of CD drives, the video must be compressed further to be able to play it back. In sum: as your frame sizes and rates go up, so do your hardware requirements.
The tracks of data on a hard drive are laid out as concentric circles, whereas a CD has a single, spiral track, like an old phonograph record. Consequently, reading data requires more processing time on a CD.
One usually designs a player panel with push buttons to play video files. Video files can either be played in the application's window or in a free-floating window. A free-floating window displays a video in motion where the window is separate from the main application window. An example of doing either follows.
class MainWindow : public IFrameWindow,
public ICommandHandler,
public ISelectHandler {
//*************************************************************
// Class: MainWindow *
// *
// Purpose: Main Window for MultiMedia sample *
// application. It is derived from IFrameWindow. *
// *
//*************************************************************
public: //Define the Public Information
MainWindow( unsigned long windowId);
~MainWindow();
protected:
bool command( ICommandEvent& event),
moving(IControlEvent& evt),
selected(IControlEvent& event);
private:
IMultiCellCanvas clientCanvas;
ICanvas *videoCanvas; // Define the canvas to place
// controls
IMMDigitalVideo videoPlayer; // Define the video player
IMMPlayerPanel btnPanel; // Define the player panel
IAnimatedButton loadBtn; // Additional button
// to load files
IRadioButton playFree, // Radio buttons
// to choose free-floating
playStatic; // or static window
);
/*-----------------------------------------------------------
| MainWindow::MainWindow
-------------------------------------------------------------*/
MainWindow::MainWindow( unsigned long windowId)
: IFrameWindow(windowId),
clientCanvas(CLIENTCANVASID,this,this),
btnPanel(PANELID, &clientCanvas, &clientCanvas),
loadBtn(LOADID, &clientCanvas, &clientCanvas, IRectangle(),
IWindow::visible | IAnimatedButton::animateWhenLatched),
playFree(FREEID, &clientCanvas, &clientCanvas, IRectangle(),
IRadioButton::defaultStyle() | IControl::group),
playStatic(STATICID, &clientCanvas, &clientCanvas),
videoPlayer(true)
{
unsigned long size = 180; // Create and attach
// the video canvas
// to the main window
videoCanvas = new ICanvas(VIDEOCANVAS, this, this);
videoCanvas->setBackgroundColor(IColor::black);
btnPanel.setPlayableDevice(&videoPlayer); // Attach video
// player to player panel
loadBtn.setBitmaps(IAnimatedButton::eject);
loadBtn.setText("Load");
playFree.setText("Play video in floating window");
playStatic.setText("Play video in static window");
playFree.select();
clientCanvas.addToCell(&btnPanel, 2, 7, 3, 1);
clientCanvas.addToCell(&loadBtn, 1, 7);
clientCanvas.addToCell(&playFree, 2, 2);
clientCanvas.addToCell(&playStatic, 2, 4);
addExtension(videoCanvas, IFrameWindow::aboveClient,
size, IFrameWindow::thinLine);
setClient(videoCanvas);
sizeTo( ISize( 400, 450 ) );
show();
setFocus();
ICommandHandler::handleEventsFor(&btnPanel);
ICommandHandler::handleEventsFor(this);
ISelectHandler::handleEventsFor(&clientCanvas);
}
/*-----------------------------------------------------------
| MainWindow::command
-------------------------------------------------------------*/
bool MainWindow::command(
ICommandEvent& evt)
{
bool rv=false;
switch (evt.commandId()) // Load the .avi file to play
{
case LOADID:
IFileDialog::Settings fdSettings;
fdSettings.setTitle("Load file");
fdSettings.setFileName("*.avi");
IFileDialog fd(desktopWindow(), this, fdSettings);
if (fd.pressedOK())
videoPlayer.loadOnThread(fd.fileName());
rv=true;
break;
}
return rv;
}
/*-----------------------------------------------------------
| MainWindow::selected
-------------------------------------------------------------*/
bool MainWindow::selected( IControlEvent& evt )
{
bool rv = false;
switch (evt.controlId()) // Handle radio buttons to switch
{ // between playing free-floaing
case STATICID: // or statically on the frame window
videoPlayer.setWindow(*videoCanvas);
rv = true;
break;
case FREEID:
videoPlayer.useDefaultWindow();
rv = true;
break;
}
return rv;
}
The following figure shows a video device using a floating window.
The following figure shows a video device displaying the video on a canvas. Note that the video window is located in the same window as the video player panel.
The device class IMMCDXA provides access to devices that read CDs for the purpose of playing compact disc-extended architecture (CD-XA) data. CD-XA refers to a storage format that accommodates data that is stored in a mixture of formats. The CD-XA data is stored in part as files, in part as video, and in part as audio. The maximum amount of storage for each is:
An application for using the IMMCDXA class might be for video CDs or movie CDs. When giving a presentation, you might want to call up different data types at different times.
This class performs the same functions as the IMMAudioCD class.
![]()
Creating Master Devices
Playing Audio Compact Discs
Creating Audio Devices
Adding Animated Buttons and
Circular Sliders
![]()
IAnimatedButton
ICircularSlider
IMMAudioCD
IMMCDXA
IMMDigitalVideo
IMMPlayerPanel
IMMRecordable
IMMWaveAudio
IMultiCellCanvas
ISliderArmHandler
IStaticText