|
I wanted to open the file with a CFile after it was played but an access error occurs.
I put an MM_MCINOTIFY callback like this:
LRESULT CWrapperDlg::OnMCIWnd_Notify(WPARAM wParam, LPARAM lParam)
{
m_mciWnd.Close();
CFile kFile;
CFileException kE;
if(kFile.Open(MakePathToInstalledFile(_T("CLOCKTXT.AVI")), CFile::modeRead, &kE))
kFile.Close();
return 0;
}
It fails with an access violation, it seems that the file is still busy.
Could you help me??
Thanks a lot
|
|
|
|
|
Hi,
I use MCIWnd to play a video in my MFC application.
Everything OK with my desktop.
But when I run my application on my laptop, the app hangs when I drag the slider of the video.
No problem when I play the video directly by WMP
WMP version is 11.0.5721.5268 and OS is WindowsXP SP3 on both machines
Does anyone experience about this?
Thanks,
TuanVo
|
|
|
|
|
Hi,
I have to display date time control on dialog box, we have DateTime control available in controls in MFC. Defaultly that is displaying 12 hours format time, but i want to display 24 hours time format.
Can any one help to how to achieve this..?
Thanks in advance..
Thanks
|
|
|
|
|
Hi,
How can i load an AviStream using the OpenInterface macro ? My code compiles just fine but it does not show anything.
void CWrapperDlg::OnPlayAVI()
{
// Create the window like you would any Windows control.
m_mciWnd.Create(WS_CHILD | WS_VISIBLE | MCIWNDF_NOPLAYBAR | MCIWNDF_NOERRORDLG | MCIWNDF_NOTIFYERROR, CRect(0, 0, 300,300), this, 1234);
// Open the AVI file.
HRESULT hr;
PAVISTREAM pstream;
AVIFileInit();
hr = AVIStreamOpenFromFile(&pstream, "test.avi", streamtypeVIDEO, 0, OF_READ, NULL);
if (FAILED(hr))
AfxMessageBox("error");
m_mciWnd.OpenInterface((PAVISTREAM) &pstream);
//m_mciWnd.Open(strAVIPath);
// Play the opened AVI file.
m_mciWnd.Play();
// To keep the demo simple - can't play the AVI file more than one time.
((CButton *)GetDlgItem(IDB_PLAY))->EnableWindow(FALSE);
}
Regards,
sdancer75
|
|
|
|
|
I hope one of these will work:
m_mciWnd.OpenInterface(pstream);
or
m_mciWnd.OpenInterface((PAVISTREAM)pstream);
|
|
|
|
|
Nope does not work. I changed the code to the following but still does nothing.
void CWrapperDlg::OnPlayAVI()
{
// Create the window like you would any Windows control.
m_mciWnd.Create(WS_CHILD | WS_VISIBLE | MCIWNDF_NOPLAYBAR | MCIWNDF_NOERRORDLG | MCIWNDF_NOTIFYERROR, CRect(0, 0, 300,300), this, 1234);
// Open the AVI file.
AVIFileInit();
IAVIFile *avi;
int res=AVIFileOpen(&avi, "C:\\tmp\\ReadAvi\\b.avi", OF_READ, NULL);
if (res!=AVIERR_OK)
{
//an error occures
if (avi!=NULL)
AVIFileRelease(avi);
return;
}
AVIFILEINFO avi_info;
AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));
CString szFileInfo;
szFileInfo.Format("Dimention: %dx%d\n"
"Length: %d frames\n"
"Max bytes per second: %d\n"
"Samples per second: %d\n"
"Streams: %d\n"
"File Type: %d", avi_info.dwWidth,
avi_info.dwHeight,
avi_info.dwLength,
avi_info.dwMaxBytesPerSec,
(DWORD) (avi_info.dwRate / avi_info.dwScale),
avi_info.dwStreams,
avi_info.szFileType);
AfxMessageBox(szFileInfo, MB_ICONINFORMATION | MB_OK);
IAVIStream *pStream;
//PAVISTREAM pStream;
res=AVIFileGetStream(avi, &pStream, streamtypeVIDEO /*video stream*/,
0 /*first stream*/);
m_mciWnd.OpenInterface(avi);
// Play the opened AVI file.
m_mciWnd.Play();
if (pStream!=NULL)
AVIStreamRelease(pStream);
// To keep the demo simple - can't play the AVI file more than one time.
AVIFileExit();
((CButton *)GetDlgItem(IDB_PLAY))->EnableWindow(FALSE);
}
You can check out the full source code at http://rapidshare.com/files/66492565/MCIWndWrapper_demo.zip.html[^]
Regards,
-- modified at 9:55 Wednesday 31st October, 2007
sdancer75
|
|
|
|
|
Hi,
Is there anyway to position my video using atime format (hh:mm:ss) ?
Currently, in frame format i use seek(pos) to position my video, but what if i want to use time format ?
Regards,
sdancer75
|
|
|
|
|
Hi
I want to encrypt my avi files and I want to play them MCIWnd. Is there any way to do that? I tried MCIWndOpenInterface but it didn't work.
Is there any way to solving this problem?
Thank you for your help
-- modified at 15:50 Wednesday 3rd May, 2006
|
|
|
|
|
earned my 5, nice easy class to work with. Great job.
I do have one suggestion though. To keep the volume the user selected volume from song to song (when they set by right clicking on the MCI control and setting it there).
Modify the Open File member function.
long CMCIWnd::Open(LPCSTR strFileName, UINT nFlags )
{
ASSERT(::IsWindow(m_hWnd));
const int iVolume = GetVolume();
const int iReturn = MCIWndOpen(m_hWnd, strFileName, nFlags);
SetVolume(iVolume);
return iReturn;
}
|
|
|
|
|
I wanted to thank you too for this code!
Good thinking
|
|
|
|
|
WOW, I had completely forgotten about this project...Thank you for the blast from the past
Common sense is admitting there is cause and effect and that you can exert some control over what you understand.
|
|
|
|
|
Hello, this problem occurs in the example program and reoccurs in a test application. It appears that when you use the MCIWnd as a control within a dialog box, the dialog box is destroyed before the MCIWnd window. So when the dialog box dissappears, the MCIWnd appears in the upper left corner of the screen. Is there a solution for this problem?
Thanks
Phil Garofalo
|
|
|
|
|
There are several ways to open a system file open dialog by MCIWnd.
1. Don't specify MCIWNDF_NOPLAYBAR in the MCIWndCreate.
At run time, click the menu button, choose "Open..."
2. MCIWndOpen(hWnd, -1, 0);
3. MCIWndOpenDialog(hWnd);
However, none of the above will succeed. Instead, violated access occurs.
Yin Jun
|
|
|
|
|
I've run into the same problem, but I've found that GetOpenFileNamePreview works.
Phil Garofalo
|
|
|
|
|
I have contacted Microsoft and they confirmed it is theiri bug.
|
|
|
|
|
Respected Sir,
Do you have any idea of how to implement the equaliser for the mci classes.we would be very grateful if you help us..
Love,
Santra![Rose | [Rose]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/rose.gif)
|
|
|
|
|
Sir,
we went through your project using the mciwnd and we have also implemented it. the play ,stop,pause and some other functions are working wheras other functions such as MCIWndSetSpeed,MCIWndSetVolume,MCIWndStep are all returning an error code of 259.we don't know how to proceed on.plz help us out as we need these functions in our project.plzzzz help us out.
thanking you,
santra
|
|
|
|
|
Hi,
Glad to help. Well for starters, to try to reproduce the problem I added:
// Step the opened AVI file.
m_mciWnd.Step(1);
in the sample program's CWrapperDlg::OnPlayAVI() function right before the line:
// Play the opened AVI file.
m_mciWnd.Play();
The call to Step() returned a 0 return code (no error) and indeed it skipped past the first frame of the video.
Try this same test with the sample application running on the machine on which you are seeing the 259 error code.
The MCI error return codes for the MCIWnd functions are in the Microsoft header file mmsystem.h. The return codes start at value 257 (MCIERR_BASE + 1). Look for the line in the file:
#define MCIERR_INVALID_DEVICE_ID (MCIERR_BASE + 1)
The return code of 259 you're getting is:
#define MCIERR_UNRECOGNIZED_KEYWORD (MCIERR_BASE + 3)
The only reference in MSDN that I could find describes this error as: "An unknown command parameter was specified."
Ok, try out the test with the sample and let me know if it works or not...but if it doesn't work, I'm not sure what to tell you. The class I wrote is really just a VERY thin wrapper around the MCIWnd calls and not much more. If you're getting an error, the problem will probably be in the MCIWnd layer and not in my class. Not much there to go wrong.
Smiles,
Paul K.
|
|
|
|
|
Respected Sir,
We tried doing what you told us to do.But still for many functions like SetVolume,SetSpeed these functions are not working.All are returning the error code of 259.no idea what to do. what can we do to set this problem straight.i think the error is in the mciwnd layer.can you help us out as to what to do with it???
Thanking You,
Santra
|
|
|
|
|
Santra,
Sorry but I really don't know much more than you about the MCIWnd API. I just wrote this very basic class that wrapped around it. In fact, I didn't like MCIWnd much in the MFC project that I did and so I ended up instead using the Macromedia Flash control with Flash files instead of using MCIWnd and AVI files. In short, you're on your own for the problems that you're experiencing right now. Good luck!
--pk
|
|
|
|
|
This is only for reference, since it's so many years since the question was asked.
I did have experienced the same problem with MCIWndSetSpeed, getting return code of 259. But I also found out that I have no problem with mp3 file. Code 259 only happened to wav file.
Regards
Lu
|
|
|
|
|
I experiment with this source and I can say if you open a video and then close it, the MCI don't release all memory allocted in the load moment. If you do this some times you've a memory leak!!! That's because I developing a multimedia player.
I modified the OnPlayAVI function to probe this.
void CWrapperDlg::OnPlayAVI()
{
// Create the window like you would any Windows control.
m_mciWnd.Create(WS_CHILD | WS_VISIBLE | MCIWNDF_NOPLAYBAR | MCIWNDF_NOERRORDLG | MCIWNDF_NOTIFYERROR, CRect(0, 0, 300,300), this, 1234);
// Open the AVI file.
CString strAVIPath = MakePathToInstalledFile(_T("a.avi"));
for (int i=0;i<10;i++)
{
m_mciWnd.Open(strAVIPath);
m_mciWnd.Play();
m_mciWnd.Stop();
m_mciWnd.Close(); // <--- These functions don't
m_mciWnd.DestroyWindow(); // <--- release the memory
}
// Play the opened AVI file.
// To keep the demo simple - can't play the AVI file more than one time.
((CButton *)GetDlgItem(IDB_PLAY))->EnableWindow(FALSE);
}
I waiting your anwsers to resolve this!!!!!
Thanks at all.
Sorry for my terrible english.
Pablo Vivera.
|
|
|
|
|
I modified MCIWnd.cpp as follows:
void CMCIWnd::Destroy()
{
ASSERT(::IsWindow(m_hWnd));
//Close();
//CWnd::OnClose();
MCIWndDestroy(m_hWnd);
}
Then in CWrapper::OnPlayAVI() ...
m_mciWnd.Play();
m_mciWnd.Stop();
m_mciWnd.Close();
m_mciWnd.Destroy();
I think this frees up m_mciWnd. Did this help?
|
|
|
|
|
Thanks for your help, but it did work. I still have the memory leak.
But I have a little more info this memory leak only ocurrs with avi files coded with divx 4.1x and divx 5.x, that's an divx's error with mci???
|
|
|
|
|
Hi,
is there a way how could be a parent's window notified, when playback is finished?
Thank you?
Lubomir
|
|
|
|
|