[英]Playing video on fullscreen mode in QT
I want to play(shared, not multiple) video file(mp4) using QMediaPlayer (with output videothread to QGraphicsVideoItem ) on multiple monitors on the single computer, connected by HDMI/DVI cable. 我想在通过HDMI / DVI电缆连接的一台计算机的多台显示器上使用QMediaPlayer (将视频线程输出到QGraphicsVideoItem )播放(共享,而不是多个)视频文件(mp4)。 I made a video playback on a single monitor, but I need to play this video on several monitors as one.
我在一台监视器上播放了视频,但是我需要在多台监视器上播放该视频。 I need of crossplatform(Linux/Windows) solution and i must provide configuration monitors for playing video in my application.
我需要跨平台(Linux / Windows)解决方案,并且必须提供配置监视器以在应用程序中播放视频。 Whether it is possible to organize a means of QT 5.4 or extended C++ libraries?
是否可以组织QT 5.4或扩展的C ++库? If yes, please prompt me the best way to do it.
如果是,请提示我最好的方法。 Sorry for bad English and thanks for the help in advance!
对不起,英语不好,谢谢您的帮助!
Hello! 你好! I need to make playing video overlay images.
我需要播放视频叠加图像。 I am used QT components QMediaPlayer and QGraphicsVideoItem to organize it.
我使用QT组件QMediaPlayer和QGraphicsVideoItem对其进行组织。 But I could not stretch the video to fill the screen(fullscreen mode).
但是我无法将视频拉伸到全屏(全屏模式)。 It looks like this:
看起来像这样:
Please, help me.
请帮我。 Thank you.
谢谢。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWebView>
#include <QVBoxLayout>
#include <QFile>
#include <QMediaPlayer>
#include <QtMultimedia>
#include <QGraphicsVideoItem>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
this->centralWidget()->setLayout(layout);
layout->addWidget(ui->graphicsView);
ui->graphicsView->setStyleSheet("background: transparent");
this->showMaximized();
QMediaPlayer * player = new QMediaPlayer();
QGraphicsVideoItem *item = new QGraphicsVideoItem;
QGraphicsScene * scene = new QGraphicsScene;
item->setSize(QSize(ui->graphicsView->width(),ui->graphicsView->height()));
ui->graphicsView->setScene(scene);
player->setVideoOutput(item);
qDebug() << item;
ui->graphicsView->scene()->addItem(item);
QPixmap pix1( "/home/ibragim/examples/ntv.png" );
player->setMedia(QUrl::fromLocalFile("/home/ibragim/examples/sm.mp4"));
player->play();
ui->graphicsView->show();
ui->graphicsView->scene()->addPixmap(pix1.scaledToHeight(100))->setPos(160,30);
}
MainWindow::~MainWindow()
{
delete ui;
}
this might do what you desire ... 这可能会满足您的需求...
void QGraphicsView::fitInView(const QGraphicsItem * item, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio)
This is an overloaded function.
Ensures that item fits tightly inside the view, scaling the view according to aspectRatioMode.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.