home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
MMSTEREO
/
MLTVID.CPP
< prev
next >
Wrap
Text File
|
1995-05-01
|
7KB
|
174 lines
#include "mltvid.hpp"
/*------------------------------------------------------------------------------
| VIDEO::VIDEO |
| |
| |
------------------------------------------------------------------------------*/
VIDEO::VIDEO( IMMDigitalVideo* aVideoPlayer,
unsigned long windowid,
IWindow* parent,
IWindow* owner)
: IMMPlayerPanel(windowid,parent,owner,IMMDevice::digitalVideo),
readout (VIDEOREADOUTID, this,this),
name (VIDEONAMEID, this, this),
pVideoPlayer (aVideoPlayer),
observer (0),
handler (0)
{
setPlayableDevice(pVideoPlayer);
loadit= new IAnimatedButton(VIDEOLOADID,this,this,IRectangle(),
IWindow::visible | IAnimatedButton::animateWhenLatched);
//Add the additional buttons to the player panel.
addToCell(&readout , 9, 1, 1, 2);
addToCell(loadit , 11, 1, 1, 2);
addToCell(&name , 2, 3, 5, 1);
playButton()->disable();
rewindButton()->disable();
fastForwardButton()->disable();
stepForwardButton()->disable();
stepBackwardButton()->disable();
//Put the bitmaps on the button.
loadit->setBitmaps(IAnimatedButton::eject);
//Put text on the button.
loadit->setText("Load");
//Set up the title
name.setText("Class Library Video Player");
name.setForegroundColor(IColor(IColor::red));
//Set up the display
IFont("LED",10).setWindowFont(&readout);
readout.setForegroundColor(IColor(0,160,0));
readout.setBackgroundColor(IColor(IColor::black));
readout.setText("HR:MIN:SEC 00:00:00");
readout.setLimit(22);
if (pVideoPlayer)
{
handler = new VideoHandler();
handler->handleEventsFor(this);
observer = new VideoObserver(*this);
observer->handleNotificationsFor(*pVideoPlayer);
}
}
/*------------------------------------------------------------------------------
| VIDEO::~VIDEO |
| |
| |
------------------------------------------------------------------------------*/
VIDEO::~VIDEO()
{
if (observer)
observer->stopHandlingNotificationsFor(*pVideoPlayer);
if (handler)
handler->stopHandlingEventsFor(this);
}
/*------------------------------------------------------------------------------
| VIDEO::videoPlayer |
| |
| |
------------------------------------------------------------------------------*/
IMMDigitalVideo* VIDEO::videoPlayer () const
{
return pVideoPlayer;
}
/*------------------------------------------------------------------------------
| VideoHandler::VideoHandler |
| |
| |
------------------------------------------------------------------------------*/
VideoHandler::VideoHandler()
: VideoHandler::Inherited()
{}
/*------------------------------------------------------------------------------
| VideoHandler::command |
| |
------------------------------------------------------------------------------*/
Boolean VideoHandler::command(ICommandEvent& event)
{
Boolean handled = false;
VIDEO* panel = 0;
switch (event.commandId())
{
case VIDEOLOADID:
{
panel = (VIDEO*) (event.window());
IFileDialog::Settings fdSettings;
fdSettings.setTitle("Load a new video file");
fdSettings.setFileName("*.avi");
IFileDialog fd(panel->desktopWindow(),panel,fdSettings);
if (fd.pressedOK())
{
panel->videoPlayer()->loadOnThread(fd.fileName());
stop(*panel);
panel->videoPlayer()->startPositionTracking(IMMTime(3000));
panel->playButton()->enable();
panel->rewindButton()->enable();
panel->fastForwardButton()->enable();
panel->stepForwardButton()->enable();
panel->stepBackwardButton()->enable();
}
}
handled=true;
break;
default:
handled = Inherited::command(event);
break;
} /* endswitch */
return handled;
}
/*------------------------------------------------------------------------------
| VideoObserver::VideoObserver |
| |
| |
------------------------------------------------------------------------------*/
VideoObserver::VideoObserver(VIDEO& videoPanel)
: VideoObserver::Inherited(),
panel(videoPanel)
{}
/*------------------------------------------------------------------------------
| VideoObserver::dispatchNotificationEvent |
| |
| |
------------------------------------------------------------------------------*/
VideoObserver& VideoObserver::dispatchNotificationEvent(const INotificationEvent& event)
{
if (event.notificationId() == IMMDevice::positionChangeId)
{
IMMPositionChangeEvent* positionEvent = (IMMPositionChangeEvent*)(event.eventData().asUnsignedLong());
IMMTime time(positionEvent->position());
panel.readout.setText(IString("HR:MIN:SEC ") +
IString(time.hours()).rightJustify(2,'0') +
":" +
IString(time.minutes()).rightJustify(2,'0') +
":" +
IString(time.seconds()).rightJustify(2,'0'));
if (!panel.playButton()->isLatched())
if (panel.videoPlayer()->mode()==IMMDevice::playing)
panel.playButton()->latch();
} /* endif */
if (event.notificationId() == IMMDevice::commandNotifyId)
{
IMMNotifyEvent* notifyEvent = (IMMNotifyEvent*)(event.eventData().asUnsignedLong());
if (notifyEvent->command() == IMMNotifyEvent::play)
panel.playButton()->unlatch();
} /* endif */
return *this;
}