Skip to content
  • 0 Votes
    2 Posts
    317 Views
    jsulmJ

    @arjun98 Did you check https://doc.qt.io/qt-5/qmediaplayer.html ? It also has signals you can use for your purpose.

  • 0 Votes
    16 Posts
    5k Views
    K

    I got the answer . MainWindow.cpp is like that

    ui->listWidget->setFlow(QListView::LeftToRight); ui->listWidget->setMinimumSize(1050,800); ui->listWidget->setGridSize(QSize(340, 320)); ui->listWidget->setResizeMode(QListView::Adjust); ui->listWidget->setViewMode(QListView::ListMode); ui->listWidget->setWrapping(true); QDir directory = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home", QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks); directory.setNameFilters({"*.mp4" , "*.avi" , "*.flv" , "*.mwv"}); for(const QFileInfo & finfo: directory.entryInfoList()){ QMediaPlayer *mediaPlayer = new QMediaPlayer(); mediaPlayer->setMedia(QUrl::fromLocalFile(finfo.absoluteFilePath())); videoItem = new QGraphicsVideoItem; videoItem->setSize(QSize(300,240)); QGraphicsScene *scene = new QGraphicsScene(this); QGraphicsView *graphicsView = new QGraphicsView(scene); mediaPlayer->setVideoOutput(videoItem); QPushButton *m_playButton = new QPushButton(); m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); connect(m_playButton, &QAbstractButton::clicked, [mediaPlayer]() { switch (mediaPlayer->state()) { case QMediaPlayer::PlayingState: mediaPlayer->pause(); break; default: mediaPlayer->play(); break; } }); connect(mediaPlayer, &QMediaPlayer::stateChanged, [m_playButton, this](QMediaPlayer::State state) { switch(state) { case QMediaPlayer::PlayingState: m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); break; default: m_playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); break; } }); QSlider *m_positionSlider = new QSlider(Qt::Horizontal,this); m_positionSlider->setRange(0,mediaPlayer->duration() / 1000); 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(m_positionSlider ,&QAbstractSlider::sliderMoved, [mediaPlayer ,this] (int position){ mediaPlayer->setPosition(position); }); auto item = new QListWidgetItem("", ui->listWidget); auto widget = new QWidget; auto label = new QLabel(finfo.fileName()); auto vb = new QVBoxLayout; QBoxLayout *controlLayout = new QHBoxLayout; controlLayout->setMargin(0); controlLayout->addWidget(m_playButton); controlLayout->addWidget(m_positionSlider); vb->addWidget(label); vb->addWidget(graphicsView); vb->addLayout(controlLayout); widget->setLayout(vb); widget->setMinimumSize(320, 320); ui->listWidget->setItemWidget(item,widget); player.append(mediaPlayer); scene->addItem(videoItem); }
  • 0 Votes
    3 Posts
    2k Views
    A

    This maybe due to the fact that our IMX6 board does not have the plugins/mediaservice particularly the libgstmediaplayer.so. Does anyone know how to create this library? And which directory in the IMX6 do I put this if I have successfully cross compiled it?