Solved Exit video full-screen
-
@mrjj Thank you so much it works, the only problem left is that the video detach from the MainWindow.
Do you know why? -
@HW-Developer
Hi
On some platforms ( Windows) the video is actual an overlay and not really inside the window.
Im not sure if that is what you are seeing ?
When you say detach from mainwindow, does it show as its own window or how does it look?
Im asking as if you dont give a QWidget ( including QVideoWidget) a parent, it will become a window on its own.
(if you show the code where u create the QVideoWidget, its easy to spot if that is the issue)
Basically the difference is like
QVideoWidget *vid= new QVideoWidget;
versus
QVideoWidget *vid= new QVideoWidget(this); <<< "this" is the parent -
@mrjj this is how it shows :
-
@HW-Developer
Super, i really think its just because your are not assigning a parent when you create it.
it then becomes a window.
So instead of replacing the other QVideoWidget you have, it just opens a (new) window.
Thats easy fixed by assigning a parent.
Did you based this off some sample i can look at ? -
@mrjj I make you a simple example, it shows the same issue:
#include "MyPlayer.h" MyPlayer::MyPlayer(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); QWidget *zoneCentrale = new QWidget; setCentralWidget(zoneCentrale); player = new QMediaPlayer(this); videoWidget = new MyVideoWidget(this); videoWidget->setGeometry(100, 100, 500, 400); fullScreen = new QPushButton("full-screen", this); layout = new QVBoxLayout(); player->setMedia(QUrl::fromLocalFile("C:/Users/ouafa/Downloads/nature.mp4")); player->setVideoOutput(videoWidget); layout->addWidget(videoWidget); layout->addWidget(fullScreen); zoneCentrale->setLayout(layout); player->setVolume(100); setCentralWidget(zoneCentrale); QObject::connect(fullScreen, SIGNAL(clicked()), this, SLOT(on_bt_agrandi_clicked())); videoWidget->show(); player->play(); qDebug()<< player->isVideoAvailable(); qDebug() << player->availableMetaData() << player->currentMedia().canonicalUrl(); } void MyPlayer::on_bt_agrandi_clicked() { if (!videoWidget->isFullScreen()) { videoWidget->setFullScreen(true); } qDebug() << "hi there!"; }
-
Hi
I could not reproduce
However, using you code 100% as is - made app crash. Not sure why.
(just tried again to be sure)This is the code i used. i rearranged it a bit and gave zoneCentrale directly to the layout.
else its pretty much the same. Can you try this ? ( change the mp4 file ofc)QWidget* zoneCentrale = new QWidget; setCentralWidget(zoneCentrale); auto player = new QMediaPlayer(this); auto videoWidget = new QVideoWidget(this); player->setVideoOutput(videoWidget); auto fullScreen = new QPushButton("full-screen", this); auto layout = new QVBoxLayout(zoneCentrale); player->setMedia(QUrl::fromLocalFile("F:/Dropbox/_qtprojects/wontdelete/test2.mp4")); layout->addWidget(videoWidget); layout->addWidget(fullScreen); player->setVolume(100); QObject::connect(fullScreen, SIGNAL(clicked()), this, SLOT(on_bt_agrandi_clicked())); videoWidget->show(); player->play();
-
@mrjj It's not working, when i make the changes, i run the app and click fullscreen button, it crash, and it blocks the app
-
@mrjj It's working after i verify everything, it is the escape key event, it should be setFullScreen(False) instead of showNormal();
I really thank you for your help. It was really nice
Good luck and have a good days -
@HW-Developer
Super.
Happy days to you too -
-
@RakeshChitte
Hi
Issue exiting fullscreen or floating window ? -
@mrjj
existing full screen... -
@RakeshChitte
Hi
Welcome back.
So what happens when you call showNormal(); ?