Qt 애플리케이션에서 비디오를 재생하고 싶습니다. 비디오가 표시되고 다시 정상적으로 재생되지만 비디오는 QVideoWidget에 맞게 크기를 조정하지 않습니다QVideoWidget : 비디오가 끊어졌습니다.
#include <QApplication>
#include <QWidget>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QUrl>
#include <iostream>
using namespace std;
const int WIDTH = 1280;
const int HEIGHT = 720;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(WIDTH, HEIGHT);
window.setWindowTitle("Video Test");
window.show();
QMediaPlayer *player = new QMediaPlayer();
player->setMedia(QUrl::fromLocalFile("/Path/To/Video.mp4"));
QVideoWidget *videoWidget = new QVideoWidget(&window);
player->setVideoOutput(videoWidget);
videoWidget->resize(WIDTH, HEIGHT);
videoWidget->show();
player->play();
return app.exec();
}
문제 : 이것은 지금까지 내 코드입니다. 위젯보다 큰 동영상 부분이 잘립니다.
미리 감사드립니다.
편집 : 나는 코드를 감소하고 응용 프로그램이 시작될 때 비디오가 차단되는 것을 발견,하지만 난 실제로 크기에 맞는 마우스를 사용하여 창 크기를 조정할 때 :
#include <QApplication>
#include <QWidget>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QUrl>
#include <iostream>
using namespace std;
const int WIDTH = 1280;
const int HEIGHT = 720;
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMediaPlayer *player = new QMediaPlayer();
QVideoWidget *videoWidget = new QVideoWidget();
player->setVideoOutput(videoWidget);
player->setMedia(QUrl::fromLocalFile("/Path/To/Video.mp4"));
player->play();
videoWidget->resize(WIDTH/3, HEIGHT/3);
videoWidget->show();
return app.exec();
}
Qon (QT + = phonon)에 포논을 추가하면 Phonon을 사용할 수 없습니다. QT의 알 수없는 모듈 : phonon. OSX btw를 실행 중입니다. 구성/설치하려면 어떻게해야합니까? – Stefan
Unfortuantely, Qt/Phonon을 OSX에서 사용하는 것에 익숙하지 않습니다. 이 주제에 대한 몇 가지 질문 [here] (http : // stackoverfl ow.com/search?q=phonon+osx) 아마도 도움이됩니다. – Exa
Phonon이 더 이상 Qt5의 일부가 아니라는 Phonon이없는 옵션이 있습니까? – Stefan