[SOLVED] What is wrong with my code when I use QVideoWidget?
-
I use QVideoWideget to show video,but it didn't show video.But at the same time I can hear the sound.
#include "widget.h"
#include <QPainter>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
setAttribute(Qt::WA_TranslucentBackground);
myPlayer=new QMediaPlayer;
videoWidget=new QVideoWidget;
mainLayout=new QHBoxLayout(this);
myPlayer->setVideoOutput(videoWidget);
videoWidget->setFixedSize(400,400);
myPlayer->setMedia(QUrl::fromLocalFile("D:/next.avi"));
mainLayout->addWidget(videoWidget);
myPlayer->play();
}Widget::~Widget()
{}
This is my code.It doesn't work in my PC,but it can work in my friend‘s PC.
My OS is Windows 10 X64. -
Check what QString errorString() returns, that you have proper codec installed.
Can you watch this avi in other program on your PC? -
@alex_malyu Yes,I can play it by other player.Does it due to I have installed two video players?I was in a mess.Maybe something wrong with my computer environment.
Still thanks!
P.S. My English is OK?haha -
Uncompressed avi is portable, but huge.
Compression is usually done by 3rd party codec.
Some codecs are installed on the system by default.
But you need codec to be available on the system if AVI used it.
Some viewers sometimes integrate codecs.
That why I assume your other program can play it.K-Lite contains mostly widely used codecs.
If you do not use such codec when creating avi, you do not have to have it installed.Fact that after installation