Media player not working for multiple videos
-
@Devopia53 No, it can:
auto l = [this]() { // use members of this here }
-
@jsulm - Yes it does not work
@Devopia53 - When I declare local variable , it works.
@aha_1980 - I will also try like U said .
Sorry for replying in the same reply . Because I am a new user . I can only post per every 600s -
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); });
-
jsulm Lifetime Qt Championreplied to Kinesis on 3 Jul 2018, 10:27 last edited by jsulm 7 Mar 2018, 10:30
@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
. -
@jsulm
Thanks for your suggestion . Now the slider is running along with video.But to use it like skip slider how should I correct this "QMediaPlayer::setPosition() " which is a slot but not a signal ?By the way , sorry for late response . -
@Kinesis You don't need
connect(mediaPlayer , &QMediaPlayer::setPosition, [mediaPlayer ,this] (int position){ mediaPlayer->setPosition(position); });
You're already using QMediaPlayer::positionChanged...
-
@Kinesis No need to feel bad - I'm helping here voluntary :-)
I don't think you need to upload your code. If somebody has questions he/she can ask. -
This post is deleted!