QT 插入视频并实现循环播放

//在头文件中声明
    QMediaPlayer *player;
    QVideoWidget *videoWidget;
    QMediaPlaylist *medialist;
  // 
 medialist=new QMediaPlaylist;
    player = new QMediaPlayer();
    videoWidget = new QVideoWidget();
    player->setVideoOutput(videoWidget);
  //  player->setMedia(QUrl::fromLocalFile("../client_new/Videos/FFTitle.mp4"));

    medialist->addMedia(QUrl::fromLocalFile("D:\\sxy\\myproject\\client_new\\Videos\\FFTitle.mp4"));
    medialist->addMedia(QUrl::fromLocalFile("D:\\sxy\\myproject\\client_new\\Videos\\mp4.mp4"));

    player->setPlaylist(medialist);
    medialist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
    player->play();
    video_group_widget=new QTableWidget();
    video_group_widget->setColumnCount(4);
    video_group_widget->setRowCount(4);
    video_group_widget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    video_group_widget->horizontalHeader()->setVisible(false);
    video_group_widget->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    video_group_widget->verticalHeader()->setVisible(false);
    video_group_widget->setShowGrid(false);
    video_group_widget->setCellWidget(0,0,videoWidget);


你可能感兴趣的:(QT编程)