sound stop Topic is solved
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
sound stop
hi once again!
I recently posted an issue in which I said that I wasnt able to stop sound...
problem is that I am able to close main window and stop sound, but if I close the Dialog in which I show the media file, then sound keeps playing...
the hint I was given was to do the following...
void MyFrame::OnClose(wxCloseEvent& WXUNUSED(event)) {
if (mediactrl->GetState() == wxMEDIASTATE_PLAYING)
dialog->Stop();
dialog->Destroy();
}
so, question is... how do I make an event that refers to a closure of a Dialog and not to a class (My Frame) ?
I recently posted an issue in which I said that I wasnt able to stop sound...
problem is that I am able to close main window and stop sound, but if I close the Dialog in which I show the media file, then sound keeps playing...
the hint I was given was to do the following...
void MyFrame::OnClose(wxCloseEvent& WXUNUSED(event)) {
if (mediactrl->GetState() == wxMEDIASTATE_PLAYING)
dialog->Stop();
dialog->Destroy();
}
so, question is... how do I make an event that refers to a closure of a Dialog and not to a class (My Frame) ?
use wxEvtHandler::Connect
Code: Select all
wxDialog dlg;
dlg.Connect( wxID_ANY,
wxEVT_CLOSE,
wxCloseEventHandler(MyFrame::OnQuit) );
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
just learned to post thing more neat
I tried that but wasnt able...
I found other things here and did this...
whats the error?
how do I implement protocol suggestion?
dlg->Conect( wxID_ANY, wxEVT_CLOSE, wxCloseEventHandler(MyFrame::OnQuit) );
and what else should I define?
thanks again!
this forum is amazing!
Luis
I tried that but wasnt able...
I found other things here and did this...
Code: Select all
void MyFrame::Connect(wxDialog *myDialog)
{
// connect events
my->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, (wxObjectEventFunction)OnQuit);
}
//then on OnQuit
void MyFrame::OnQuit(wxCloseEvent& WXUNUSED(event))
{
if (mediactrl->GetState() == wxMEDIASTATE_PLAYING)
mediactrl->Stop();
//this->Destroy();
//iguDialog->Destroy();
}
how do I implement protocol suggestion?
dlg->Conect( wxID_ANY, wxEVT_CLOSE, wxCloseEventHandler(MyFrame::OnQuit) );
and what else should I define?
thanks again!
this forum is amazing!
Luis
Hi!
Could you post some more code? Especially where do you create the media control and what events should be connected to which handler.
Could you post some more code? Especially where do you create the media control and what events should be connected to which handler.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
upcase:
here they are the main parts of the code
here they are the main parts of the code
Code: Select all
void OnQuit(wxCloseEvent &event);
void Connect(wxDialog *iguDialog);
wxMediaCtrl *mediaCtrl;
wxDialog *myDialog;
EVT_CLOSE(MyFrame::OnQuit)
mediaCtrl = new wxMediaCtrl();
myDialog = new wxDialog(this, -1, "dialog", wxPoint(300,100), wxSize(400,400), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxTHICK_FRAME ,"dialogBox");
myDialog->SetBackgroundColour(wxColour(0, 0, 0));
mediaCtrl->Create(myDialog, ID_MEDIA, fd.GetPath(), wxPoint(0, 0), wxSize(1024,768));
void MyFrame::OnQuit(wxCloseEvent& WXUNUSED(event))
{
if (mediaCtrl->GetState() == wxMEDIASTATE_PLAYING)
mediaCtrl->Stop();
}
void MyFrame::Connect(wxDialog *myDialog)
{
myDialog->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, (wxObjectEventFunction)OnQuit);
}
try this:
Hope that works.
Code: Select all
myDialog->Connect( myDialog->GetId(), wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(MyFrame::OnQuit) );
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
-
- Super wx Problem Solver
- Posts: 396
- Joined: Wed Oct 05, 2005 1:19 am
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
The close event fires when the event is raised/emitted ( wxWindow::Close() ). So you will or should close the dialog before you call mediaCtrl->Stop().
Also if you really want the music to stop playing you can try deleting the pointer, and then re-instantiate it (mediaCtrl) if you need access it again.
Also if you really want the music to stop playing you can try deleting the pointer, and then re-instantiate it (mediaCtrl) if you need access it again.
Code: Select all
if (mediaCtrl->GetState() == wxMEDIASTATE_PLAYING) {
delete mediaCtrl;
this->Destroy();
}
// mediaCtrl = new wxMediaCtrl( ... ); // if needed again
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay
-
- Knows some wx things
- Posts: 44
- Joined: Tue Mar 28, 2006 9:44 pm
- Location: Montevideo, Uruguay