Results 1 to 9 of 9

Thread: Phonon::videoplayer doubt

  1. #1
    Join Date
    May 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Phonon::videoplayer doubt

    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

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Phonon::videoplayer doubt

    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.

  3. #3
    Join Date
    May 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Re: Phonon::videoplayer doubt

    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

    Qt Code:
    1. videoplayer=new Phonon::VideoPlayer(Phonon::VideoCategory,this);
    2. videoplayer->setGeometry(QRect(190, 85, 547, 364));
    3.  
    4.  
    5. volumeSlider = new Phonon::VolumeSlider(this);
    6. volumeSlider->setObjectName(QString::fromUtf8("volumeSlider"));
    7. volumeSlider->setGeometry(QRect(614, 465, 100, 22));
    8. volumeSlider->setAudioOutput(videoplayer->audioOutput());
    9. volumeSlider->setMuteVisible(true);
    10. volumeSlider->setStyleSheet(" background:none; border:none;");
    11. volumeSlider->setCursor(Qt::PointingHandCursor);
    12.  
    13. seeksilder = new Phonon::SeekSlider(this);
    14. seeksilder->setGeometry(QRect(390, 465, 210, 22));
    15. seeksilder->setMediaObject(videoplayer->mediaObject());
    16. seeksilder->setStyleSheet(" background:none; border:none;");
    17. seeksilder->setCursor(Qt::PointingHandCursor);
    18.  
    19. videoplayer->load(Phonon::MediaSource ("mybirthdayparty.wmv"));
    20. videoplayer->play(Phonon::MediaSource("mybirthdayparty.wmv"));
    To copy to clipboard, switch view to plain text mode 




    This

    Qt Code:
    1. void Videoplayerclass::on_pic1_clicked()
    2. {
    3. videoplayer->stop();
    4. videoplayer->hide();
    5. videoplayer->deleteLater();
    6. delete videoplayer;
    7. Nextwindow *n=new Nextwindow;
    8.  
    9. n->show();
    10. this->hide();
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by vishnu717; 23rd June 2011 at 07:04.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Phonon::videoplayer doubt

    What is the Videoplayerclass ?

    Qt Code:
    1. void Videoplayerclass::on_pic1_clicked()
    2. {
    3. videoplayer->stop();
    4. videoplayer->hide();
    5. videoplayer->deleteLater(); // this is ok
    6. //delete videoplayer; //Not required if using videoplayer->deleteLater(), use only one of these
    7. Nextwindow *n=new Nextwindow; //missing parent is this new top level window?
    8.  
    9. n->show();
    10. this->hide();
    11. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    May 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Re: Phonon::videoplayer doubt

    Videoplayerclass is the class in which videoplayer is declared .

    actually my classs name is Videoplayerclass

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Phonon::videoplayer doubt

    You are hiding Videoplayerclass, so how do you get it back ?
    Where does control go when Nextwindow is closed / hidden ?

  7. #7
    Join Date
    May 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Re: Phonon::videoplayer doubt

    Inside the Nextwindow , iam creating another instance of Videoplayerclass inside the button click


    Qt Code:
    1. void Nextwindow ::on_button_clicked()
    2. {
    3. Videoplayerclass *other = new Videoplayerclass ;
    4. other->show();
    5. this->hide();
    6. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Phonon::videoplayer doubt

    There is a memory leak, you should be doing like this

    Qt Code:
    1. void Videoplayerclass::on_pic1_clicked()
    2. {
    3. videoplayer->stop();
    4. videoplayer->hide();
    5. videoplayer->deleteLater();
    6.  
    7. Nextwindow *n = new Nextwindow;
    8. n->show();
    9.  
    10. this->hide();
    11. this->deleteLater();
    12. }
    13.  
    14. void Nextwindow::on_button_clicked()
    15. {
    16. Videoplayerclass *other = new Videoplayerclass;
    17. other->show();
    18.  
    19. this->hide();
    20. this->deleteLater();
    21. }
    To copy to clipboard, switch view to plain text mode 

  9. The following user says thank you to Santosh Reddy for this useful post:

    vishnu717 (23rd June 2011)

  10. #9
    Join Date
    May 2011
    Posts
    16
    Thanks
    3
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows

    Default Re: Phonon::videoplayer doubt

    Thank u very much Sir


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


    Added after 1 50 minutes:


    The following code also worked for me by calling destructor
    Qt Code:
    1. void Videoplayerclass::on_pic1_clicked()
    2. {
    3. videoplayer->stop();
    4. videoplayer->hide();
    5. videoplayer->deleteLater();
    6.  
    7. Nextwindow *n = new Nextwindow;
    8. n->show();
    9.  
    10. this->hide();
    11. this->~Videoplayerclass();
    12. }
    13.  
    14.  
    15. void Nextwindow::on_button_clicked()
    16. {
    17. Videoplayerclass *other = new Videoplayerclass;
    18. other->show();
    19.  
    20. this->hide();
    21. this->~Nextwindow();
    22. }
    To copy to clipboard, switch view to plain text mode 




    then in the destructor

    Qt Code:
    1. Videoplayerclass::~Videoplayerclass()
    2. {
    3. delete ui;
    4. delete videoplayer;
    5. }
    6. Nextwindow::~Nextwindow()
    7. {
    8. delete ui;
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by vishnu717; 23rd June 2011 at 09:50.

Similar Threads

  1. Phonon::VideoPlayer
    By dano_labrosse in forum Newbie
    Replies: 6
    Last Post: 1st February 2012, 06:33
  2. Problem in phonon videoplayer
    By vinayaka in forum Newbie
    Replies: 1
    Last Post: 20th January 2012, 11:55
  3. How to set a background in a Phonon VideoPlayer ?
    By slimIT in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2010, 21:54
  4. phonon VideoPlayer refresh
    By rbp in forum Qt Programming
    Replies: 6
    Last Post: 14th November 2008, 01:56
  5. phonon VideoPlayer seek
    By rbp in forum Qt Programming
    Replies: 4
    Last Post: 31st October 2008, 04:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.