Register mediainfo with QML. Display HDR type
This commit is contained in:
parent
411e6e3b55
commit
eeaec187cb
@ -31,18 +31,31 @@ Window {
|
||||
anchors.rightMargin: 25
|
||||
color: "lightgrey"
|
||||
height: txtVideoFile.font.pixelSize + 10
|
||||
id: txtBackground
|
||||
|
||||
TextEdit {
|
||||
id: txtVideoFile
|
||||
text: ""
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 15
|
||||
verticalAlignment: TextEdit.AlignVCenter
|
||||
anchors.fill: parent
|
||||
readOnly: false
|
||||
selectByMouse: true
|
||||
font.pixelSize: 14
|
||||
anchors.leftMargin: 15
|
||||
anchors.rightMargin: 15
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
//TODO Need to scroll and clip long text
|
||||
id: hdrType
|
||||
anchors.left: btnVideoFile.left
|
||||
anchors.top: txtBackground.bottom
|
||||
width: 200
|
||||
text: "None"
|
||||
wrapMode: TextEdit.Wrap
|
||||
}
|
||||
|
||||
|
||||
|
||||
FileDialog {
|
||||
@ -50,6 +63,22 @@ Window {
|
||||
fileMode: FileDialog.OpenFile
|
||||
nameFilters: ["Video files (*.mkv *.mp4)", "All files (*)"]
|
||||
onAccepted: { const reg = /^file:\/\/\// //Remove "file:/// at start of URL
|
||||
txtVideoFile.text = videoFileDialog.selectedFile.toString().replace(reg, "") }
|
||||
var fileName = videoFileDialog.selectedFile.toString().replace(reg, "")
|
||||
txtVideoFile.text = fileName
|
||||
|
||||
switch (mediaInfo.getHDRType(fileName)) {
|
||||
case 0:
|
||||
hdrType.text = "SDR"
|
||||
break
|
||||
case 1:
|
||||
hdrType.text = "HDR"
|
||||
break
|
||||
case 2:
|
||||
hdrType.text = "Dolby Vision"
|
||||
break
|
||||
default:
|
||||
hdrType.text = "Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,17 @@
|
||||
#include <myMediaInfo.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QQmlContext>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
myMediaInfo mInfo;
|
||||
myMediaInfo mInfo(&app);
|
||||
|
||||
//Check if HDR/DolbyVision
|
||||
enum myMediaInfo::HDR hdrType = mInfo.getHDR(__T("Cosmos.mkv"));
|
||||
enum myMediaInfo::HDR_Type hdrType = mInfo.getHDRType(__T("Cosmos.mkv"));
|
||||
if (hdrType >= 0) {
|
||||
qInfo() << hdrType;
|
||||
} else {
|
||||
@ -21,6 +22,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextProperty("mediaInfo", &mInfo);
|
||||
|
||||
const QUrl url(u"qrc:/DoViGUI/Main.qml"_qs);
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreationFailed,
|
||||
&app, []() { QCoreApplication::exit(-1); },
|
||||
|
@ -1,14 +1,14 @@
|
||||
#include "myMediaInfo.h"
|
||||
#include "MediaInfoDLL.h"
|
||||
#include "qvariant.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
myMediaInfo::myMediaInfo() {
|
||||
|
||||
}
|
||||
myMediaInfo::myMediaInfo(QObject *parent){}
|
||||
|
||||
enum myMediaInfo::HDR myMediaInfo::getHDR(const MediaInfoDLL::String fileName) {
|
||||
enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const MediaInfoDLL::String fileName) {
|
||||
if (Open(fileName)) {
|
||||
MediaInfoDLL::String HDRtext = Get(MediaInfoDLL::Stream_Video, 0, __T("HDR_Format"), MediaInfoDLL::Info_Text, MediaInfoDLL::Info_Name);
|
||||
Close();
|
||||
@ -23,3 +23,7 @@ enum myMediaInfo::HDR myMediaInfo::getHDR(const MediaInfoDLL::String fileName) {
|
||||
}
|
||||
return ERR;
|
||||
}
|
||||
|
||||
enum myMediaInfo::HDR_Type myMediaInfo::getHDRType(const QString fileName) {
|
||||
return getHDRType(fileName.toStdWString());
|
||||
}
|
||||
|
@ -2,16 +2,19 @@
|
||||
#define MYMEDIAINFO_H
|
||||
|
||||
#include <QObject>
|
||||
//#include "qvariant.h"
|
||||
#include <MediaInfoDLL.h>
|
||||
|
||||
class myMediaInfo : public MediaInfoDLL::MediaInfo{
|
||||
// Q_OBJECT
|
||||
class myMediaInfo : public QObject, public MediaInfoDLL::MediaInfo {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
myMediaInfo();
|
||||
enum HDR{ERR = -1, SDR = 0, HDR = 1, DOVI = 2};
|
||||
myMediaInfo(QObject* parent = nullptr);
|
||||
enum HDR_Type{ERR = -1, SDR = 0, HDR = 1, DOVI = 2};
|
||||
Q_ENUM(HDR_Type)
|
||||
|
||||
enum HDR getHDR(const MediaInfoDLL::String fileName);
|
||||
enum HDR_Type getHDRType(const MediaInfoDLL::String fileName);
|
||||
Q_INVOKABLE enum HDR_Type getHDRType(QString fileName);
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user