mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-15 06:52:34 +02:00
Add working webm player. WARNING: THERE IS NO ERROR FOR PLAYING MP4 YET IMPLEMENTED!
This commit is contained in:
parent
a278d0d36d
commit
324ab64637
@ -5,13 +5,11 @@
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QStringList argumentList = a.arguments();
|
||||
QStringList argumentList = a.arguments();
|
||||
|
||||
if(argumentList.length() != 7) {
|
||||
if (argumentList.length() != 7) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
@ -23,8 +21,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// Args: which monitor, path to project, wallpaper secret to identify the connected socket
|
||||
MainWindow w(monitor,argumentList.at(2), argumentList.at(3),argumentList.at(4),argumentList.at(5),argumentList.at(6));
|
||||
//MainWindow w(0,"D:/672870/827148653");
|
||||
//MainWindow w(monitor, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), argumentList.at(6));
|
||||
//MainWindow w(0,"D:/672870/827148653","","","","");
|
||||
MainWindow w(monitor, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), argumentList.at(6));
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
TEMPLATE = app
|
||||
QT += qml quick quickcontrols2 widgets core
|
||||
CONFIG += c++17
|
||||
CONFIG += qtquickcompiler
|
||||
#CONFIG += qtquickcompiler
|
||||
msvc: LIBS += -luser32
|
||||
TARGETPATH = ScreenPlayWindow
|
||||
|
||||
@ -28,9 +28,15 @@ CONFIG(debug, debug|release) {
|
||||
}
|
||||
|
||||
|
||||
install_it.files += index.html \
|
||||
|
||||
INSTALLS += install_it
|
||||
|
||||
DISTFILES += \
|
||||
index.html
|
||||
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
QML_IMPORT_PATH += [QtAVSourceCodeDir]/qml
|
||||
QML_IMPORT_PATH += "C:\msys64\mingw64\share\qt5\qml"
|
||||
QML_IMPORT_PATH =
|
||||
|
||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
||||
QML_DESIGNER_IMPORT_PATH =
|
||||
@ -46,8 +52,3 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
win32 {
|
||||
INCLUDEPATH += "C:\msys64\mingw64\include"
|
||||
}
|
||||
|
||||
|
23
ScreenPlayWindow/index.html
Normal file
23
ScreenPlayWindow/index.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
video {
|
||||
object-fit: fill;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
}
|
||||
body, html{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
overflow: hidden;
|
||||
background:orange;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<video id="videoPlayer" oncontextmenu="return false;" width="100%" height="100%" loop muted autoplay>
|
||||
<source id="videoSource" src="https://www.aimber.net/walk.webm" type="video/webm" oncontextmenu="return false;" width="100%" height="100%"> Your browser does not support the video tag.
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
@ -1,36 +1,28 @@
|
||||
import QtQuick 2.9
|
||||
import QtWebEngine 1.6
|
||||
import net.aimber.screenplaysdk 1.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: "gray"
|
||||
color: "transparent"
|
||||
anchors.fill: parent
|
||||
property string tmpVideoPath
|
||||
property var jsonProjectFile
|
||||
|
||||
Component.onCompleted: {
|
||||
|
||||
|
||||
// jsonProjectFile = JSON.parse(mainwindow.projectConfig)
|
||||
|
||||
// if(jsonProjectFile.type === "qmlScene"){
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
ScreenPlaySDK {
|
||||
id: spSDK
|
||||
contentType: "ScreenPlayWindow"
|
||||
appID: mainwindow.appID
|
||||
|
||||
onIncommingMessageError: {
|
||||
//rctError.opacity = 1
|
||||
//txtDebug.text = "ERROR: " + msg.toString()
|
||||
|
||||
}
|
||||
onIncommingMessage: {
|
||||
var obj2 = 'import QtQuick 2.9; Item {Component.onCompleted: sceneLoader.item.' + key + ' = ' + value + '; }'
|
||||
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
|
||||
newObject.destroy(10000)
|
||||
|
||||
|
||||
// var obj2 = 'import QtQuick 2.9; Item {Component.onCompleted: sceneLoader.item.' + key + ' = ' + value + '; }'
|
||||
// var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
|
||||
// newObject.destroy(10000)
|
||||
}
|
||||
|
||||
onSdkConnected: {
|
||||
@ -38,8 +30,6 @@ Rectangle {
|
||||
}
|
||||
|
||||
onSdkDisconnected: {
|
||||
//name.text = "disconnected"
|
||||
screenVideo.state = "destroy"
|
||||
mainwindow.destroyThis()
|
||||
}
|
||||
}
|
||||
@ -48,53 +38,60 @@ Rectangle {
|
||||
target: mainwindow
|
||||
|
||||
onPlayVideo: {
|
||||
screenVideo.videoPath = path
|
||||
//screenVideoLoader.setSource("qrc:/ScreenVideo.qml", {videoPath: path})
|
||||
|
||||
}
|
||||
onPlayQmlScene: {
|
||||
var tmp = Qt.resolvedUrl("file:///" + file)
|
||||
print(tmp)
|
||||
sceneLoader.setSource(tmp)
|
||||
mainwindow.init()
|
||||
|
||||
}
|
||||
|
||||
onDecoderChanged:{
|
||||
screenVideo.decoder = decoder
|
||||
onDecoderChanged: {
|
||||
|
||||
}
|
||||
onFillModeChanged:{
|
||||
screenVideo.fillMode = fillMode
|
||||
onFillModeChanged: {
|
||||
|
||||
}
|
||||
onLoopsChanged:{
|
||||
screenVideo.loops = loops
|
||||
onLoopsChanged: {
|
||||
|
||||
}
|
||||
onVolumeChanged:{
|
||||
screenVideo.volume = volume
|
||||
onVolumeChanged: {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ScreenVideo {
|
||||
id: screenVideo
|
||||
}
|
||||
|
||||
// Loader {
|
||||
// id:screenVideoLoader
|
||||
// anchors.fill: parent
|
||||
// }
|
||||
Loader {
|
||||
id: sceneLoader
|
||||
WebEngineView {
|
||||
id: webView
|
||||
anchors.fill: parent
|
||||
url: Qt.resolvedUrl("file:///" + mainwindow.getApplicationPath() + "/index.html")
|
||||
onLoadProgressChanged: {
|
||||
print(loadProgress)
|
||||
if (loadProgress === 100) {
|
||||
timerShowDelay.start()
|
||||
}
|
||||
}
|
||||
userScripts: [scriptPlayer]
|
||||
onJavaScriptConsoleMessage: print(message)
|
||||
settings.allowRunningInsecureContent: true
|
||||
|
||||
WebEngineScript {
|
||||
id: scriptPlayer
|
||||
injectionPoint: WebEngineScript.DocumentReady
|
||||
worldId: WebEngineScript.MainWorld
|
||||
sourceCode: {
|
||||
return "var videoPlayer = document.getElementById('videoPlayer');
|
||||
var videoSource = document.getElementById('videoSource');
|
||||
videoSource.src = \"file:///" + mainwindow.fullContentPath + "\";
|
||||
videoPlayer.load();"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: rctError
|
||||
opacity: 0
|
||||
height: 300
|
||||
width: 600
|
||||
anchors.centerIn: parent
|
||||
Text {
|
||||
id: txtDebug
|
||||
font.pixelSize: 32
|
||||
anchors.centerIn: parent
|
||||
Timer {
|
||||
id: timerShowDelay
|
||||
interval: 2000
|
||||
onTriggered: {
|
||||
mainwindow.init()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "SPWmainwindow.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
|
||||
@ -14,6 +15,7 @@ BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder, QString volume, QString fillmode, QScreen* parent)
|
||||
: QWindow(parent)
|
||||
{
|
||||
@ -52,6 +54,20 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
|
||||
if (m_project.contains("file"))
|
||||
m_projectFile = m_project.value("file").toString();
|
||||
|
||||
if (m_project.contains("type")) {
|
||||
if (m_project.value("type") == "video") {
|
||||
QString tmpPath = m_projectPath.toString() + "/" + m_projectFile;
|
||||
setFullContentPath(tmpPath);
|
||||
|
||||
emit playVideo(tmpPath);
|
||||
} else if (m_project.value("type") == "scene") {
|
||||
return;
|
||||
} else if (m_project.value("type") == "qmlScene") {
|
||||
QString tmpPath = m_projectPath.toString() + "/" + m_projectFile;
|
||||
emit playQmlScene(tmpPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Recalculate window coordiantes because of point (0,0)
|
||||
// Is at the origin monitor or the most left
|
||||
QScreen* screen = QApplication::screens().at(i);
|
||||
@ -116,28 +132,17 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
|
||||
}
|
||||
});
|
||||
|
||||
if (m_project.contains("type")) {
|
||||
if (m_project.value("type") == "video") {
|
||||
QString tmpPath = m_projectPath.toString() + "/" + m_projectFile;
|
||||
|
||||
emit playVideo(tmpPath);
|
||||
} else if (m_project.value("type") == "scene") {
|
||||
return;
|
||||
} else if (m_project.value("type") == "qmlScene") {
|
||||
QString tmpPath = m_projectPath.toString() + "/" + m_projectFile;
|
||||
emit playQmlScene(tmpPath);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void MainWindow::init()
|
||||
{
|
||||
setOpacity(0);
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
|
||||
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
|
||||
#endif
|
||||
setOpacity(0);
|
||||
QPropertyAnimation* animation = new QPropertyAnimation(this, "opacity");
|
||||
animation->setDuration(200);
|
||||
//animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
@ -146,6 +151,11 @@ void MainWindow::init()
|
||||
animation->start();
|
||||
}
|
||||
|
||||
QString MainWindow::getApplicationPath()
|
||||
{
|
||||
return QApplication::applicationDirPath();
|
||||
}
|
||||
|
||||
void MainWindow::setScreenNumber(const QVector<int>& screenNumber)
|
||||
{
|
||||
m_screenNumber = screenNumber;
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QEasingCurve>
|
||||
@ -16,9 +15,11 @@
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <qt_windows.h>
|
||||
#endif
|
||||
|
||||
class MainWindow : public QWindow {
|
||||
Q_OBJECT
|
||||
|
||||
@ -36,6 +37,7 @@ public:
|
||||
Q_PROPERTY(QString fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
|
||||
Q_PROPERTY(bool loops READ loops WRITE setLoops NOTIFY loopsChanged)
|
||||
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
|
||||
|
||||
|
||||
QString projectConfig() const
|
||||
@ -86,6 +88,11 @@ public:
|
||||
return m_decoder;
|
||||
}
|
||||
|
||||
QString fullContentPath() const
|
||||
{
|
||||
return m_fullContentPath;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void destroyThis();
|
||||
void init();
|
||||
@ -155,6 +162,17 @@ public slots:
|
||||
emit decoderChanged(m_decoder);
|
||||
}
|
||||
|
||||
QString getApplicationPath();
|
||||
|
||||
void setFullContentPath(QString fullContentPath)
|
||||
{
|
||||
if (m_fullContentPath == fullContentPath)
|
||||
return;
|
||||
|
||||
m_fullContentPath = fullContentPath;
|
||||
emit fullContentPathChanged(m_fullContentPath);
|
||||
}
|
||||
|
||||
signals:
|
||||
void playVideo(QString path);
|
||||
void playQmlScene(QString file);
|
||||
@ -167,6 +185,8 @@ signals:
|
||||
void volumeChanged(float volume);
|
||||
void decoderChanged(QString decoder);
|
||||
|
||||
void fullContentPathChanged(QString fullContentPath);
|
||||
|
||||
private:
|
||||
#ifdef Q_OS_WIN
|
||||
HWND m_hwnd;
|
||||
@ -185,4 +205,5 @@ private:
|
||||
bool m_loops;
|
||||
float m_volume;
|
||||
QString m_decoder;
|
||||
QString m_fullContentPath;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user