Results 1 to 2 of 2

Thread: Connecting QMediaPlayer object to horizontal slider?

  1. #1
    Join Date
    Jul 2014
    Posts
    46
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Connecting QMediaPlayer object to horizontal slider?

    How can I do this? Since phonon has been removed for version 5 and above, how do I show the status of my mediaplayer on a horizontal slider?
    I tried doing this:
    Qt Code:
    1. ui->hs->setRange(0, player.duration() / 1000);
    2. ui->hs->setEnabled(player.duration() > 0);
    3. connect(ui->hs, SIGNAL(valueChanged(int)), this, SLOT(seek(int)));
    4.  
    5.  
    6. void MainWindow::seek(int seconds)
    7. {
    8. player.setPosition(seconds * 1000);
    9. }
    To copy to clipboard, switch view to plain text mode 

    This does not even activate my horizontal slider. What is the issue?

  2. #2
    Join Date
    Mar 2015
    Posts
    6
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Connecting QMediaPlayer object to horizontal slider?

    Example here :
    https://github.com/obiwankennedy/rol...ayerwidget.cpp
    Qt Code:
    1. connect(&m_player,SIGNAL(positionChanged(qint64)),this,SLOT(positionChanged(qint64)));
    To copy to clipboard, switch view to plain text mode 


    and

    Qt Code:
    1. void PlayerWidget::positionChanged(qint64 time)
    2. {
    3. QTime displayTime(0, (time / 60000) % 60, (time / 1000) % 60);
    4. if((!m_preferences->value("isPlayer",false).toBool()) && ((time>m_time+(FACTOR_WAIT*m_player.notifyInterval()))||(time<m_time)))
    5. {
    6. emit playerPositionChanged(m_id,time);
    7. }
    8. m_time = time;
    9. m_ui->m_timeSlider->setValue(time);
    10. m_ui->m_timerDisplay->display(displayTime.toString("mm:ss"));
    11. }
    To copy to clipboard, switch view to plain text mode 

    In fact, there is an issue about the type. You have to put a slot in the middle.
    Last edited by anda_skoa; 23rd March 2015 at 11:20. Reason: changed [quote] to [code]

Similar Threads

  1. Replies: 4
    Last Post: 15th August 2013, 02:51
  2. Replies: 0
    Last Post: 20th February 2012, 15:31
  3. Replies: 0
    Last Post: 8th July 2011, 05:52
  4. Replies: 0
    Last Post: 8th July 2011, 05:04
  5. Replies: 0
    Last Post: 7th July 2011, 11:47

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
  •  
Qt is a trademark of The Qt Company.