Board index » cppbuilder » Error occurs when remove a dynamicly defined TMediaPlayer Component

Error occurs when remove a dynamicly defined TMediaPlayer Component


2006-01-19 02:25:06 PM
cppbuilder91
Things to do: add a temporary TMediaPlayer compont to the main
form,play the media.At the same time, start a thread to remove this
TMediaPlayer in a setted time.
//////////////////////the action to add a TMediaPlayer
compont/////////////////////////////////////
TMediaPlayer *mpl;
mpl=new TMediaPlayer(MainForm);//MainForm is the parent form
mpl->Visible=false;
mpl->Parent=MainForm;
mpl->Name="Player";
mpl->FileName=file_name;//file_name is the media name defined
mpl->Open();
mpl->Play();//uo to this,everything is ok,the media play well;
THDisplayTimeIsUp *test=new THDisplayTimeIsUp(false);
//start the thread,when the setted time is up,clear this TMediaPlayer;
//the Execute() method in THDisplayTimeIsUp is somthing like this:
Sleep(1000);
MainForm->ClearStim("Player");
///////////////////////////////////////////////////////////////
//the ClearStim is defined as following:
void __fastcall TMainForm::ClearStim(String remove_name)
{
TControl *t2;
for(int i=MainForm->ControlCount-1;i>=0;i--)
{
t2=MainForm->Controls;
if(t2->Name=="Player")
{
MainForm->RemoveControl(t2);//ERROR HERE!!!!
t2->Free();
break;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Error Message:
"Project raised exception class EOSError with message "System Error.
Code:5. Access denied.";
Why this occurs?
I have checked,it's sure that the TMediaPlayer "Player" is among in the
Controls of MainForm;
I try replace the TMediaPlay with TImage compont ,and everything is OK.
No such error occurs. So the error above is caused by some properties
of TMediaPlayer itself,and I deal them wrong?
HELP ME~I'm quite puzzled now.
 
 

Re:Error occurs when remove a dynamicly defined TMediaPlayer Component

Things to do: add a temporary TMediaPlayer compont to the main
form,play the media.At the same time, start a thread to remove this
TMediaPlayer in a set time.
//////////////////////the action to add a TMediaPlayer
compont/////////////////////////////////////
TMediaPlayer *mpl;
mpl=new TMediaPlayer(MainForm);//MainForm is the parent form
mpl->Visible=false;
mpl->Parent=MainForm;
mpl->Name="Player";
mpl->FileName=file_name;//file_name is the media name defined
mpl->Open();
mpl->Play();//uo to this,everything is ok,the media play well;
THDisplayTimeIsUp *test=new THDisplayTimeIsUp(false);
//start the thread,when the set time is up,clear this TMediaPlayer;
//the Execute() method in THDisplayTimeIsUp is somthing like this:
Sleep(1000);
MainForm->ClearStim("Player");
///////////////////////////////////////////////////////////////
//the ClearStim is defined as following:
void __fastcall TMainForm::ClearStim(String remove_name)
{
TControl *t2;
for(int i=MainForm->ControlCount-1;i>=0;i--)
{
t2=MainForm->Controls;
if(t2->Name=="Player")
{
MainForm->RemoveControl(t2);//ERROR HERE!!!!
t2->Free();
break;
}
}
}
///////////////////////////////////////////////////////////////////////////?///////////////////////////////////////
Error Message:
"Project raised exception class EOSError with message "System Error.
Code:5. Access denied.";
Why this occurs?
I have checked,it's sure that the TMediaPlayer "Player" is among in the
Controls of MainForm after adding action;
I try replace the TMediaPlay with TImage compont ,and everything is OK.
No such error occurs. So the error above is caused by some properties
of TMediaPlayer itself,and I deal them wrong?
HELP ME~
I'm quite puzzled now.