From: George P Benson <George P on
Hi There,

I'm a total amateur writing a nifty little jukebox for my house, with a few
bits of security in preparation for a party... ;)

As a result I'm trying to use Visual C++ with an Windows Media Player
ActiveX control.... And getting absolutely nowhere... Can anyone shed any
light on the methods I need to use?

Also I can't seem to find out how to query id3 tag data with c++...

Anyone out there who's can help a bewildered newbie??

Cheers
From: AliR on
How are you doing it now? Where are you stuck.
Here is what I would do.
Go to your resource editor, and add the ActiveX control that you want. (How
to do this depends on your Development Env). Visual C++ .Net, as far as I
know you have to create a dialog or something, then right click on it and
select insert ActiveX control. Visual C++ 6.0 from anywhere you can go
through the menu Project - Add to Project - Component and Controls.
Then create a member variable to it.
Now if you have inserted Windows Media Player then you should have a file
called mediaplayer.h in your project. Open that to see what methods you have
available.
It should have put_Filename to open the file you want.
and there should be a Play, Pause, and Stop methods.

Is that what you are looking for?

AliR.

"George P Benson" <George P Benson(a)discussions.microsoft.com> wrote in
message news:AB1BAA98-36F4-4531-A7B3-A2C639947CAF(a)microsoft.com...
> Hi There,
>
> I'm a total amateur writing a nifty little jukebox for my house, with a
few
> bits of security in preparation for a party... ;)
>
> As a result I'm trying to use Visual C++ with an Windows Media Player
> ActiveX control.... And getting absolutely nowhere... Can anyone shed any
> light on the methods I need to use?
>
> Also I can't seem to find out how to query id3 tag data with c++...
>
> Anyone out there who's can help a bewildered newbie??
>
> Cheers


From: AliR on
I fogot to mention, a few years a go I was using the Media Player ActiveX
control. I can't remember why but it pissed me off a bit. I think it was
the fact that I didn't much control over the size and placement of the
movies that I was playing. Anyway I decided to use the mci calls from the
SDK if you are intrested in that.
///////////////////////////////////////////// LSMCI.h
/////////////////////////////////////////
#ifndef __LSMCI_H__
#define __LSMCI_H__

#include <mmsystem.h>

class LSMci
{
public:

LSMci();
~LSMci();

BOOL OpenMovie(CString Filename,CWnd *TheWnd);
BOOL PlayMovie(BOOL FullScreen = FALSE);
void PauseMovie();
BOOL StopMovie();
BOOL CloseMovie();
BOOL PositionMovie(CPoint Point,BOOL FullScreen = FALSE,BOOL Center =
TRUE);

BOOL PlaySound(CString Filename,BOOL Async);
BOOL StopSound();


private:
MCIDEVICEID m_DeviceID;
BOOL m_MovieOpen;
HWND m_hWndMovie;
BOOL m_Playing;
CWnd *m_NotifyWnd;

};

#endif

///////////////////////////////////////////// LSMCI.cpp
/////////////////////////////////////////
#include "stdafx.h"
#include "LSMci.h"
#include <digitalv.h>
#include <MciAvi.h>

#define AVI_VIDEO "avivideo"


LSMci::LSMci()
:m_DeviceID(0),
m_MovieOpen(FALSE),
m_Playing(FALSE)
{
}

LSMci::~LSMci()
{

}


BOOL LSMci::OpenMovie(CString Filename,CWnd *TheWnd)
{
MCI_DGV_OPEN_PARMS mciOpen;
MCI_DGV_WINDOW_PARMS mciWindow;
MCI_DGV_STATUS_PARMS mciStatus;

m_NotifyWnd = TheWnd;

/* we have a .AVI movie to open, use MCI */
/* set up the open parameters */
mciOpen.dwCallback = 0L;
mciOpen.wDeviceID = 0;
mciOpen.lpstrDeviceType = NULL; //(char *)MCI_DEVTYPE_DIGITAL_VIDEO;
mciOpen.lpstrElementName = Filename.GetBuffer(MAX_PATH);
mciOpen.lpstrAlias = NULL;
mciOpen.dwStyle = WS_CHILD;
mciOpen.hWndParent = TheWnd->GetSafeHwnd();

/* try to open the file */
if (mciSendCommand(0, MCI_OPEN,

(DWORD)(MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_DGV_OPEN_WS),//|MCI_OPEN_TY
PE),
(DWORD)(LPMCI_DGV_OPEN_PARMS)&mciOpen) == 0){

/* we opened the file o.k., now set up to */
/* play it. */
m_DeviceID = mciOpen.wDeviceID; /* save ID */
m_MovieOpen = TRUE; /* a movie was opened */

/* show the playback window */
mciWindow.dwCallback = 0L;
mciWindow.hWnd = NULL;
mciWindow.nCmdShow = SW_SHOW;
mciWindow.lpstrText = (LPSTR)NULL;
mciSendCommand(m_DeviceID, MCI_WINDOW,
MCI_DGV_WINDOW_STATE,
(DWORD)(LPMCI_DGV_WINDOW_PARMS)&mciWindow);

/* get the window handle */
mciStatus.dwItem = MCI_DGV_STATUS_HWND;
mciSendCommand(m_DeviceID,
MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPMCI_STATUS_PARMS)&mciStatus);
m_hWndMovie = (HWND)mciStatus.dwReturn;
}
else
{
m_MovieOpen = FALSE;
}

return m_MovieOpen;
}

BOOL LSMci::PlayMovie(BOOL FullScreen)
{
m_Playing = !m_Playing; /* swap the play flag */

/* play/pause the AVI movie */
if (m_Playing)
{
DWORD dwFlags;
MCI_DGV_PLAY_PARMS mciPlay;

/* init to play all */
mciPlay.dwCallback = MAKELONG(m_NotifyWnd->GetSafeHwnd(),0);
mciPlay.dwFrom = mciPlay.dwTo = 0;
dwFlags = MCI_NOTIFY | MCI_WAIT;
if (FullScreen)
{
dwFlags |= MCI_MCIAVI_PLAY_FULLSCREEN;
}

mciSendCommand(m_DeviceID, MCI_PLAY, dwFlags,
(DWORD)(LPMCI_DGV_PLAY_PARMS)&mciPlay);
return TRUE;
}
else
{
MCI_DGV_PAUSE_PARMS mciPause;

/* tell it to pause */
mciSendCommand(m_DeviceID,MCI_PAUSE,0L,
(DWORD)(LPMCI_DGV_PAUSE_PARMS)&mciPause);
return TRUE;
}

return FALSE;
}

BOOL StopMovie()
{
return FALSE;
}


void LSMci::PauseMovie()
{
MCI_DGV_PAUSE_PARMS mciPause;

/* tell it to pause */
mciSendCommand(m_DeviceID,MCI_PAUSE,0L,
(DWORD)(LPMCI_DGV_PAUSE_PARMS)&mciPause);

}


BOOL LSMci::PositionMovie(CPoint Point,BOOL FullScreen,BOOL Center)
{
CRect rcMovie; /* the rect where the movie is positioned */
/* for QT/W this is the movie rect, for AVI */
/* this is the location of the playback window */
RECT rcClient, rcMovieBounds;
MCI_DGV_RECT_PARMS mciRect;

/* if there is no movie yet then just get out of here */
if (!m_MovieOpen)
return FALSE;

m_NotifyWnd->GetClientRect(&rcClient); /* get the parent windows rect */

/* get the original size of the movie */
mciSendCommand(m_DeviceID, MCI_WHERE,
(DWORD)(MCI_DGV_WHERE_SOURCE),
(DWORD)(LPMCI_DGV_RECT_PARMS)&mciRect);
CopyRect( &rcMovieBounds, &mciRect.rc ); /* get it in the movie bounds rect
*/

if (FullScreen)
{
rcMovie.left = 0;
rcMovie.top = 0;
rcMovie.right = 640;
rcMovie.bottom = 480;
}
else if (Center)
{
rcMovie.left = (rcClient.right/2) - (rcMovieBounds.right / 2);
rcMovie.top = (rcClient.bottom/2) - (rcMovieBounds.bottom / 2);
rcMovie.right = rcMovie.left + rcMovieBounds.right;
rcMovie.bottom = rcMovie.top + rcMovieBounds.bottom;
}
else
{
rcMovie = rcMovieBounds;
rcMovie.OffsetRect(Point);
}

/* reposition the playback (child) window */
MoveWindow(m_hWndMovie, rcMovie.left, rcMovie.top,
rcMovieBounds.right, rcMovieBounds.bottom, TRUE);

/* cause a total repaint to occur */
m_NotifyWnd->Invalidate();
m_NotifyWnd->UpdateWindow();

return TRUE;
}


BOOL LSMci::CloseMovie()
{
MCI_GENERIC_PARMS mciGeneric;

mciSendCommand(m_DeviceID, MCI_CLOSE, 0L,
(DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);

m_Playing = FALSE; // can't be playing any longer
m_MovieOpen = FALSE; // no more movies open


/* cause a total repaint to occur */
m_NotifyWnd->Invalidate();
m_NotifyWnd->UpdateWindow();

return TRUE;
}


BOOL LSMci::PlaySound(CString Filename,BOOL Async)
{
return sndPlaySound(Filename,Async ? SND_ASYNC : SND_SYNC);
}

BOOL LSMci::StopSound()
{
return sndPlaySound(NULL,SND_ASYNC);
}



 | 
Pages: 1
Prev: VC6 to VC7.1
Next: XP Themes on Forms