3 Nisan 2017 Pazartesi

QT- QVİDEO PLAYER

videoplayer.pro

#-------------------------------------------------
#
# Project created by QtCreator 2017-04-03T15:39:03
#
#-------------------------------------------------

QT       += core gui multimedia multimediawidgets



greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = videoplayer
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += main.cpp\
        dialog.cpp

HEADERS  += dialog.h

FORMS    += dialog.ui



--------------------------------------------------------------------

dialog.h

#ifndef DIALOG_H
#define DIALOG_H

#include < QDialog>

namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

private:
    Ui::Dialog *ui;
};

#endif // DIALOG_H

------------------------------------------------------------------------------

dialog.cpp


#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui- > ;setupUi(this);
}

Dialog::~Dialog()
{
    delete ui;
}

----------------------------------------------------------------------------
main.cpp

#include "dialog.h"
#include < QApplication>
#include< QMediaPlayer>
#include< QVideoWidget>
#include< QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    // Dialog w;
    // w.show();
   QMediaPlayer* player = new QMediaPlayer;
   QVideoWidget* vw = new QVideoWidget;
   player->setVideoOutput(vw);
   player->setMedia(QUrl::fromLocalFile("//C://Users//dtsis//Desktop//vi.mpg"));
   vw->setGeometry(100,100,300,400);
   vw->show();
   player->play();
   qDebug() << player->state();

    return a.exec();
}
Share: