PDA

View Full Version : Phonon::videoplayer doubt



vishnu717
22nd June 2011, 11:31
I am creating a phonon video player. In my project , i have to navigate to and from the video player page.
videoplayer is quit working 3 or more times when navigated. But after that, only audio is heared, the video is not displayed...

my doubts,

* How to kill instances of videoplayer when naviagted.(on button click)

i used videoplayer->deletelater(); and videoplayer->~videoplayer(); But the error visual studio just in time debugger displays "new instance is created ".

* how to use inheritance in qt so that i can control videoplayer in all my subclasses

Santosh Reddy
23rd June 2011, 06:54
hide the videoplayer widget and then can safely call vivideoplayer->deletelater(), if calling from one of the slots of videoplayer, else can call delete videoplayer; directly.


how to use inheritance in qt so that i can control videoplayer in all my subclasses
inherit as if it were just another widget, is there any problem in doing so.

vishnu717
23rd June 2011, 07:57
i used videoplayer->hide(); in one of my slots
and i also tried with delete videoplayer


But the error visual studio just in time debugger displays "new instance is created ".



the error lines are below

" unhandled win32 exception occured in videoplayer.exe"
Possible debuggers

new instance of visual studio 2008

Do you wantto debug using selected debugger?



here is my code for videoplayer



videoplayer=new Phonon::VideoPlayer(Phonon::VideoCategory,this);
videoplayer->setGeometry(QRect(190, 85, 547, 364));


volumeSlider = new Phonon::VolumeSlider(this);
volumeSlider->setObjectName(QString::fromUtf8("volumeSlider"));
volumeSlider->setGeometry(QRect(614, 465, 100, 22));
volumeSlider->setAudioOutput(videoplayer->audioOutput());
volumeSlider->setMuteVisible(true);
volumeSlider->setStyleSheet(" background:none; border:none;");
volumeSlider->setCursor(Qt::PointingHandCursor);

seeksilder = new Phonon::SeekSlider(this);
seeksilder->setGeometry(QRect(390, 465, 210, 22));
seeksilder->setMediaObject(videoplayer->mediaObject());
seeksilder->setStyleSheet(" background:none; border:none;");
seeksilder->setCursor(Qt::PointingHandCursor);

videoplayer->load(Phonon::MediaSource ("mybirthdayparty.wmv"));
videoplayer->play(Phonon::MediaSource("mybirthdayparty.wmv"));






This




void Videoplayerclass::on_pic1_clicked()
{
videoplayer->stop();
videoplayer->hide();
videoplayer->deleteLater();
delete videoplayer;
Nextwindow *n=new Nextwindow;

n->show();
this->hide();
}

Santosh Reddy
23rd June 2011, 08:04
What is the Videoplayerclass ?


void Videoplayerclass::on_pic1_clicked()
{
videoplayer->stop();
videoplayer->hide();
videoplayer->deleteLater(); // this is ok
//delete videoplayer; //Not required if using videoplayer->deleteLater(), use only one of these
Nextwindow *n=new Nextwindow; //missing parent is this new top level window?

n->show();
this->hide();
}

vishnu717
23rd June 2011, 08:07
Videoplayerclass is the class in which videoplayer is declared .

actually my classs name is Videoplayerclass

Santosh Reddy
23rd June 2011, 08:12
You are hiding Videoplayerclass, so how do you get it back ?
Where does control go when Nextwindow is closed / hidden ?

vishnu717
23rd June 2011, 08:24
Inside the Nextwindow , iam creating another instance of Videoplayerclass inside the button click




void Nextwindow ::on_button_clicked()
{
Videoplayerclass *other = new Videoplayerclass ;
other->show();
this->hide();
}

Santosh Reddy
23rd June 2011, 08:40
There is a memory leak, you should be doing like this


void Videoplayerclass::on_pic1_clicked()
{
videoplayer->stop();
videoplayer->hide();
videoplayer->deleteLater();

Nextwindow *n = new Nextwindow;
n->show();

this->hide();
this->deleteLater();
}

void Nextwindow::on_button_clicked()
{
Videoplayerclass *other = new Videoplayerclass;
other->show();

this->hide();
this->deleteLater();
}

vishnu717
23rd June 2011, 10:50
Thank u very much Sir


Its working...................

Added after 1 50 minutes:

The following code also worked for me by calling destructor


void Videoplayerclass::on_pic1_clicked()
{
videoplayer->stop();
videoplayer->hide();
videoplayer->deleteLater();

Nextwindow *n = new Nextwindow;
n->show();

this->hide();
this->~Videoplayerclass();
}


void Nextwindow::on_button_clicked()
{
Videoplayerclass *other = new Videoplayerclass;
other->show();

this->hide();
this->~Nextwindow();
}






then in the destructor




Videoplayerclass::~Videoplayerclass()
{
delete ui;
delete videoplayer;
}
Nextwindow::~Nextwindow()
{
delete ui;
}