Media player not working for multiple videos
Solved
General and Desktop
-
@Devopia53 No, it can:
auto l = [this]() { // use members of this here }
-
I still have a question . I replaced the slider slots into loop but I can't control the sliders and sliders are not moving when the videos are running .
Here is the slider codeQSlider *m_positionSlider = new QSlider(Qt::Horizontal); m_positionSlider->setRange(0, 0); connect(mediaPlayer, &QMediaPlayer::positionChanged ,[m_positionSlider, this](qint64 position){ m_positionSlider->setValue(position); }); connect(mediaPlayer, &QMediaPlayer::durationChanged ,[m_positionSlider, this](qint64 duration){ m_positionSlider->setRange(0,duration); }); connect(mediaPlayer , &QMediaPlayer::setPosition, [mediaPlayer ,this] (int position){ mediaPlayer->setPosition(position); });
-
@Kinesis What is this:
connect(mediaPlayer , &QMediaPlayer::setPosition, [mediaPlayer ,this] (int position){ mediaPlayer->setPosition(position); });
?
QMediaPlayer::setPosition() is a slot not a signal.
I think you need to change the rangem_positionSlider->setRange(0, 0);
You can use http://doc.qt.io/qt-5/qmediaplayer.html#duration-prop to set the range.
-
I know that well(as
[&]
or[=]
). But what I have described is that you have captured the member variables of thethis
object directly. Take a look at his source code. here:connect(mediaPlayer, &QMediaPlayer::stateChanged, [m_playButton, this](QMediaPlayer::State state)
Am_playButton
is a member of thethis
. -
-
This post is deleted!