1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 20:22:39 +01:00
This commit is contained in:
kelteseth 2018-09-06 13:57:36 +02:00
parent b916734a73
commit 300f98aff0
24 changed files with 243 additions and 269 deletions

View File

@ -46,6 +46,7 @@ ApplicationWindow {
sidebar.state = "inactive"
}
}
Connections {
target: screenPlaySettings
onSetMainWindowVisible: {
@ -112,11 +113,11 @@ ApplicationWindow {
if (miMuteAll.isMuted) {
isMuted = false
miMuteAll.text = qsTr("Mute all")
screenPlaySettings.setMuteAll(false)
screenPlay.setWallpaperValue(0, "volume", "1")
} else {
isMuted = true
miMuteAll.text = qsTr("Unmute all")
screenPlaySettings.setMuteAll(true)
screenPlay.setWallpaperValue(0, "volume", "0")
}
}
}
@ -128,11 +129,11 @@ ApplicationWindow {
if (miStopAll.isPlaying) {
isPlaying = false
miStopAll.text = qsTr("Pause all")
screenPlaySettings.setPlayAll(true)
screenPlay.setWallpaperValue(0, "isPlaying", "false")
} else {
isPlaying = true
miStopAll.text = qsTr("Play all")
screenPlaySettings.setPlayAll(false)
screenPlay.setWallpaperValue(0, "isPlaying", "true")
}
}
}
@ -181,17 +182,6 @@ ApplicationWindow {
}
}
// Loader {
// id: pageLoaderCommunity
// visible: false
// asynchronous: true
// anchors {
// top: nav.bottom
// right: parent.right
// bottom: parent.bottom
// left: parent.left
// }
// }
Loader {
id: pageLoaderWorkshop
visible: false

View File

@ -183,7 +183,7 @@ Item {
Text {
id: txtHeadlineMonitor
text: qsTr("Select a Monitor to display the content")
height: 20
height: 50
renderType: Text.NativeRendering
horizontalAlignment: Qt.AlignHCenter
font.family: "Roboto"
@ -192,7 +192,7 @@ Item {
wrapMode: Text.WrapAnywhere
anchors {
top: headlineWrapper.bottom
topMargin: 20
margins: 20
right: parent.right
left: parent.left
}
@ -289,6 +289,7 @@ Item {
}
Text {
visible: false
id: txtComboBoxFillMode
text: qsTr("Fill Mode")
height: 30
@ -306,6 +307,7 @@ Item {
}
ComboBox {
visible: false
id: settingsComboBox
width: 200

View File

@ -123,7 +123,7 @@ void InstalledListModel::loadScreens()
if (!obj.contains("type")) {
obj.insert("type", "video");
}
if (fileEnding.endsWith(".webm"))
if (fileEnding.endsWith(".webm") || (obj.value("type").toString() == "qmlScene"))
emit addInstalledItem(obj, item.baseName());
}
}

View File

@ -54,7 +54,7 @@ QHash<int, QByteArray> ProjectSettingsListModel::roleNames() const
void ProjectSettingsListModel::init(QString file)
{
qDebug() << file;
qDebug() << "ProjectSettingsListModel loading: " << file;
QFile configTmp;
configTmp.setFileName(file);
QJsonDocument configJsonDocument;

View File

@ -106,6 +106,8 @@ QVector<int> ScreenPlay::getMonitorByAppID(QString appID)
return m_screenPlayWallpaperList.at(i).data()->screenNumber();
}
}
return QVector<int>();
}
Settings* ScreenPlay::settings() const

View File

@ -9,12 +9,16 @@ SDKConnector::SDKConnector(QObject* parent)
m_server = QSharedPointer<QLocalServer>(new QLocalServer(this));
connect(m_server.data(), &QLocalServer::newConnection, this, &SDKConnector::newConnection);
if (!m_server.data()->listen("ScreenPlay")) {
//TODO
}
}
void SDKConnector::readyRead()
{
}
void SDKConnector::newConnection()
{
m_clients.append(QSharedPointer<SDKConnection>(new SDKConnection(m_server.data()->nextPendingConnection())));
@ -77,11 +81,6 @@ void SDKConnector::setSceneValue(QString appID, QString key, QString value)
}
void SDKConnection::setSocket(QLocalSocket* socket)
{
m_socket = socket;
}
QLocalSocket* SDKConnection::socket() const
{
return m_socket;

View File

@ -26,6 +26,7 @@ public:
signals:
public slots:
void readyRead();
void newConnection();
void closeAllWallpapers();
void closeWallpapersAt(int at);
@ -56,7 +57,6 @@ public:
qDebug() << "destroying SDKConnection Object";
}
void setSocket(QLocalSocket* socket);
QString appID() const
{

View File

@ -29,7 +29,7 @@
#include "profilelistmodel.h"
#include "projectsettingslistmodel.h"
#include "sdkconnector.h"
#include "steam/steam_api.h"
#include "../ThirdParty/steam/steam_api.h"
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif

View File

@ -1,5 +1,8 @@
#include "steamworkshop.h"
#include "stdlib.h"
#include "cstring"
SteamWorkshop::SteamWorkshop(QObject* parent)
: QObject(parent)
{
@ -97,6 +100,7 @@ void SteamWorkshop::submitWorkshopItem(QString title, QString description, QStri
if (!jsonObject.contains("workshopid")) {
jsonObject.insert("workshopid", publishedFileId);
}
projectConfig.close();
// Reopen to empty the file via Truncate
projectConfig.open(QIODevice::ReadWrite | QIODevice::Truncate);
@ -109,17 +113,21 @@ void SteamWorkshop::submitWorkshopItem(QString title, QString description, QStri
SteamUGC()->SetItemUpdateLanguage(m_UGCUpdateHandle, QByteArray(language.toLatin1()).data());
SteamUGC()->SetItemContent(m_UGCUpdateHandle, QByteArray(absoluteContentPath.toLatin1()).data());
SteamUGC()->SetItemPreview(m_UGCUpdateHandle, QByteArray(preview.toLatin1()).data());
auto tagList = new QScopedPointer<SteamParamStringArray_t>(new SteamParamStringArray_t);
//const char** cchKey[5][2000];
//tagList->data()->m_ppStrings = cchKey;
//tagList->data()->m_nNumStrings = 1;
//tagList->data()->m_ppStrings[1][0] = QByteArray("asas").data();
SteamUGC()->SetItemTags(m_UGCUpdateHandle, tagList->data());
auto visibility = static_cast<ERemoteStoragePublishedFileVisibility>(remoteStoragePublishedFileVisibility);
SteamUGC()->SetItemVisibility(m_UGCUpdateHandle, visibility);
auto tagList = new QScopedPointer<SteamParamStringArray_t>(new SteamParamStringArray_t);
int numStrings = 2;
tagList->data()->m_nNumStrings = numStrings;
const char *a[2];
a[0] = "Videos";
a[1] = "Scenes";
tagList->data()->m_ppStrings = a;
SteamUGC()->SetItemTags(m_UGCUpdateHandle, tagList->data());
SteamUGC()->SubmitItemUpdate(m_UGCUpdateHandle, nullptr);
emit remoteWorkshopCreationStatusChanged(RemoteWorkshopCreationStatus::Started);
@ -152,7 +160,6 @@ bool SteamWorkshop::contentFolderExist(QString folder)
}
}
void SteamWorkshop::subscribeItem(unsigned int id)
{
SteamUGC()->SubscribeItem(static_cast<unsigned long long>(id));
@ -178,7 +185,7 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
if (bIOFailure)
return;
//QtConcurrent::run([this, pCallback]() { });
QtConcurrent::run([this, &pCallback]() { });
SteamUGCDetails_t details;
const int urlLength = 200;
@ -194,10 +201,11 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
char* pchValue[cchValueSize];
uint32 results = pCallback->m_unTotalMatchingResults;
qDebug() << "ok " << results;
for (uint32 i = 0; i < results; i++) {
if (SteamUGC()->GetQueryUGCResult(pCallback->m_handle, i, &details)) {
//qDebug() << "ok " << pCallback;
if (SteamUGC()->GetQueryUGCPreviewURL(pCallback->m_handle, i, url, static_cast<uint32>(urlLength))) {
QByteArray urlData(url);
@ -223,7 +231,9 @@ void SteamWorkshop::onWorkshopSearched(SteamUGCQueryCompleted_t* pCallback, bool
qDebug() << "Loading error!";
}
}
SteamUGC()->ReleaseQueryUGCRequest(pCallback->m_handle);
}
void SteamWorkshop::onWorkshopItemInstalled(ItemInstalled_t* itemInstalled)

View File

@ -1,7 +1,7 @@
#pragma once
#include "settings.h"
#include "steam/steam_api.h"
#include "../ThirdParty/steam/steam_api.h"
#include "steamworkshoplistmodel.h"
#include <QByteArray>
#include <QDateTime>

View File

@ -3,7 +3,6 @@
SteamWorkshopListModel::SteamWorkshopListModel(QObject* parent)
: QAbstractListModel(parent)
{
}
QHash<int, QByteArray> SteamWorkshopListModel::roleNames() const
@ -74,7 +73,6 @@ void SteamWorkshopListModel::append(unsigned int id, QString title, QUrl imgUrl,
void SteamWorkshopListModel::addWorkshopItem(WorkshopItem wi)
{
}
QUrl SteamWorkshopListModel::getBannerUrl()
@ -106,7 +104,6 @@ void SteamWorkshopListModel::setBannerWorkshopItem(unsigned int id, QString titl
m_workshopBannerItem.m_title = title;
m_workshopBannerItem.m_previewImageUrl = imgUrl;
m_workshopBannerItem.m_numSubscriptions = numSubscriptions;
}
bool SteamWorkshopListModel::setData(const QModelIndex& index, const QVariant& value, int role)

View File

@ -4,6 +4,7 @@
#include <QDebug>
#include <QSharedPointer>
#include <QVector>
#include <QVariant>
#include "workshopitem.h"

View File

@ -0,0 +1,7 @@
SOURCES += \
$$PWD/screenplay-sdk_plugin.cpp \
$$PWD/screenplaysdk.cpp
HEADERS += \
$$PWD/screenplay-sdk_plugin.h \
$$PWD/screenplaysdk.h

View File

@ -8,12 +8,12 @@ uri = net.aimber.screenplaysdk
# Input
SOURCES += \
screenplay-sdk_plugin.cpp \
screenplaysdk.cpp
$$PWD/screenplay-sdk_plugin.cpp \
$$PWD/screenplaysdk.cpp
HEADERS += \
screenplay-sdk_plugin.h \
screenplaysdk.h
$$PWD/screenplay-sdk_plugin.h \
$$PWD/screenplaysdk.h
DISTFILES = qmldir

View File

@ -1,21 +1,54 @@
#include "screenplaysdk.h"
ScreenPlaySDK::ScreenPlaySDK(QQuickItem *parent):
QQuickItem(parent)
{
// By default, QQuickItem does not draw anything. If you subclass
// QQuickItem to create a visual item, you will need to uncomment the
// following line and re-implement updatePaintNode()
// USE THIS ONLY FOR redirectMessageOutputToMainWindow
static ScreenPlaySDK* global_sdkPtr = nullptr;
// setFlag(ItemHasContents, true);
m_socket = QSharedPointer<QLocalSocket>(new QLocalSocket());
m_socket.data()->setServerName("ScreenPlay");
QObject::connect(m_socket.data(), &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
QObject::connect(m_socket.data(), &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
QObject::connect(m_socket.data(), &QLocalSocket::bytesWritten, this, &ScreenPlaySDK::bytesWritten);
QObject::connect(m_socket.data(), &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
QObject::connect(m_socket.data(), QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, &ScreenPlaySDK::error);
m_socket.data()->connectToServer();
void redirectMessageOutputToMainWindow(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
if (global_sdkPtr == nullptr)
return;
QByteArray localMsg = msg.toLocal8Bit();
QByteArray file = "File: " + QByteArray(context.file) + ", ";
QByteArray line = "in line " + QByteArray::number(context.line) + ", ";
//QByteArray function = "function " + QByteArray(context.function) + ", Message: ";
localMsg = file + line + localMsg;
switch (type) {
case QtDebugMsg:
localMsg = "Debug " /*+ QByteArray::fromStdString(global_sdkPtr->contentType().toStdString()) + " "*/ + localMsg;
global_sdkPtr->redirectMessage(localMsg);
break;
case QtInfoMsg:
//fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtWarningMsg:
//fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
//fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtFatalMsg:
//(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
}
}
ScreenPlaySDK::ScreenPlaySDK(QQuickItem* parent)
: QQuickItem(parent)
{
global_sdkPtr = this;
m_socket.setServerName("ScreenPlay");
connect(&m_socket, &QLocalSocket::connected, this, &ScreenPlaySDK::connected);
connect(&m_socket, &QLocalSocket::disconnected, this, &ScreenPlaySDK::disconnected);
connect(&m_socket, &QLocalSocket::bytesWritten, this, &ScreenPlaySDK::bytesWritten);
connect(&m_socket, &QLocalSocket::readyRead, this, &ScreenPlaySDK::readyRead);
connect(&m_socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, &ScreenPlaySDK::error);
m_socket.connectToServer();
// Redirect all messages from this to ScreenPlay
qInstallMessageHandler(redirectMessageOutputToMainWindow);
}
ScreenPlaySDK::~ScreenPlaySDK()
@ -36,12 +69,11 @@ void ScreenPlaySDK::disconnected()
void ScreenPlaySDK::bytesWritten(qint64 bytes)
{
}
void ScreenPlaySDK::readyRead()
{
QString tmp = m_socket.data()->readAll();
QString tmp = m_socket.readAll();
QJsonParseError err;
auto doc = QJsonDocument::fromJson(QByteArray::fromStdString(tmp.toStdString()), &err);
@ -59,9 +91,15 @@ void ScreenPlaySDK::readyRead()
void ScreenPlaySDK::error(QLocalSocket::LocalSocketError socketError)
{
emit sdkSocketError("Error");
if (socketError == QLocalSocket::LocalSocketError::ConnectionRefusedError) {
//QCoreApplication::quit();
QCoreApplication::quit();
}
}
void ScreenPlaySDK::redirectMessage(QByteArray& msg)
{
if (isConnected()) {
m_socket.write(msg);
m_socket.waitForBytesWritten();
}
}

View File

@ -7,10 +7,12 @@
#include <QLocalServer>
#include <QLocalSocket>
#include <QObject>
#include <QPluginLoader>
#include <QQuickItem>
#include <QSharedDataPointer>
#include <QSharedPointer>
#include <QTimer>
#include <QtGlobal>
class ScreenPlaySDK : public QQuickItem {
Q_OBJECT
@ -39,12 +41,14 @@ public:
return m_appID;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
void redirectMessage(QByteArray &msg);
void setContentType(QString contentType)
{
@ -54,9 +58,9 @@ public slots:
m_contentType = contentType;
if (isConnected()) {
m_socket.data()->write(QByteArray(m_contentType.toLatin1()));
m_socket.data()->flush();
m_socket.data()->waitForBytesWritten();
m_socket.write(QByteArray(m_contentType.toLatin1()));
m_socket.flush();
m_socket.waitForBytesWritten();
}
emit contentTypeChanged(m_contentType);
}
@ -78,25 +82,28 @@ public slots:
m_appID = appID;
emit appIDChanged(m_appID);
m_socket.data()->write(QByteArray(appID.toUtf8()));
m_socket.data()->waitForBytesWritten();
m_socket.write(QByteArray(appID.toUtf8()));
m_socket.waitForBytesWritten();
}
private:
//qint64 writeData(const char *data, qint64 c) override;
signals:
void incommingMessage(QString key, QString value);
void incommingMessageError(QString msg);
void sdkConnected();
void sdkDisconnected();
void sdkSocketError(QString type);
void contentTypeChanged(QString contentType);
void isConnectedChanged(bool isConnected);
void appIDChanged(QString appID);
void newRedirectMessage(QByteArray &msg);
private:
QSharedPointer<QLocalSocket> m_socket;
QLocalSocket m_socket;
QString m_contentType = "undefined";
bool m_isConnected = false;

View File

@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>ScreenVideo.qml</file>
</qresource>
</RCC>

View File

@ -1,29 +1,37 @@
#include "../ScreenPlaySDK/screenplaysdk.h"
#include "src/SPWmainwindow.h"
#include <QApplication>
#include <QObject>
#include <QStringList>
int main(int argc, char* argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
ScreenPlaySDK sdk;
// 6 parameter + 1 OS working directory default paramter
QStringList argumentList = a.arguments();
if (argumentList.length() != 7) {
return -3;
}
bool ok = false;
int monitor = argumentList.at(1).toInt(&ok);
bool canParseMonitorNumber = false;
int monitor = argumentList.at(1).toInt(&canParseMonitorNumber);
if (!ok) {
if (!canParseMonitorNumber) {
return -4;
}
// 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));
// Args: which monitor, (2) path to project, (3)wallpaper secret to identify the connected socket, (4) decoder, (5) volume, (6) fillmode
// See screenplay.h @ScreenPlayWallpaper constructor how the args get created
// MainWindow w(0,"D:/672870/827148653","","","","");
qDebug() << "Starting: " << argumentList.at(2) << argumentList.at(3) << argumentList.at(4) << argumentList.at(5)<< argumentList.at(6);
MainWindow w(monitor, argumentList.at(2), argumentList.at(3), argumentList.at(4), argumentList.at(5), argumentList.at(6));
QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &w, &MainWindow::destroyThis);
return a.exec();
}

View File

@ -1,7 +1,7 @@
TEMPLATE = app
QT += qml quick quickcontrols2 widgets core
CONFIG += c++17
#CONFIG += qtquickcompiler
CONFIG += qtquickcompiler
msvc: LIBS += -luser32
TARGETPATH = ScreenPlayWindow
@ -20,13 +20,17 @@ INCLUDEPATH += \
$$PWD/../../ThirdParty/ \
$$PWD/../../src/ \
include(../ScreenPlaySDK/Screenplaysdk.pri)
LIBS += -lScreenplaysdk
CONFIG(debug, debug|release) {
install_it.path = $${OUT_PWD}/debug/
QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK/debug
} else {
install_it.path = $${OUT_PWD}/release/
QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK/release
}
QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK
install_it.files += index.html \
@ -52,3 +56,5 @@ DEFINES += QT_DEPRECATED_WARNINGS
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@ -1,93 +0,0 @@
import QtQuick 2.9
import QtAV 1.7
Rectangle {
id: screenVideoPlayer
color: "black"
anchors.fill: parent
property string videoPath
property string decoder: "DXVA" //["CUDA", "VAAPI", "D3D11", "DXVA", "FFmpeg"]
property string fillMode
onFillModeChanged: {
if(fillMode === "Stretch"){
videoOut.fillMode = VideoOutput.Stretch
} else if(fillMode === "PreserveAspectFit"){
videoOut.fillMode = VideoOutput.PreserveAspectFit
} else if(fillMode === "PreserveAspectCrop"){
videoOut.fillMode = VideoOutput.PreserveAspectCrop
}
}
property bool loops: true
property real volume: 0
onVideoPathChanged: {
player.source = Qt.resolvedUrl("file:///" + videoPath)
player.play()
}
property bool isPlaying: true
VideoOutput2 {
id: videoOut
anchors.fill: parent
source: player
opengl: true
fillMode: VideoOutput.Stretch
}
MediaPlayer {
id: player
videoCodecPriority: screenVideoPlayer.decoder
loops: MediaPlayer.Infinite
volume: screenVideoPlayer.volume
onPlaybackStateChanged: {
if (player.playbackState === MediaPlayer.PlayingState) {
state = "playing"
mainwindow.init()
}
}
}
states: [
State {
name: "playing"
PropertyChanges {
target: player
volume: screenVideoPlayer.volume
}
},
State {
name: "destroy"
PropertyChanges {
target: player
volume: 0
}
}
]
transitions: [
Transition {
from: "*"
to: "playing"
reversible: true
NumberAnimation {
target: player
property: "volume"
duration: 1000
}
},
Transition {
from: "playing"
to: "destroy"
reversible: true
NumberAnimation {
target: player
property: "volume"
duration: 200
}
}
]
}

View File

@ -17,7 +17,7 @@
</style>
</head>
<body>
<video id="videoPlayer" oncontextmenu="return false;" width="100%" height="100%" loop muted autoplay>
<video id="videoPlayer" oncontextmenu="return false;" width="100%" height="100%" loop autoplay>
<source id="videoSource" src="" type="video/webm" oncontextmenu="return false;" width="100%" height="100%"> Your browser does not support the video tag.
</video>
</body>

View File

@ -1,6 +1,5 @@
import QtQuick 2.9
import QtWebEngine 1.6
import net.aimber.screenplaysdk 1.0
Rectangle {
id: root
@ -9,31 +8,6 @@ Rectangle {
property string tmpVideoPath
property var jsonProjectFile
ScreenPlaySDK {
id: spSDK
contentType: "ScreenPlayWindow"
appID: mainwindow.appID
onIncommingMessageError: {
}
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)
}
onSdkConnected: {
}
onSdkDisconnected: {
mainwindow.destroyThis()
}
}
Connections {
target: mainwindow
@ -44,9 +18,6 @@ Rectangle {
}
onDecoderChanged: {
}
onFillModeChanged: {
}
@ -54,27 +25,47 @@ Rectangle {
}
onVolumeChanged: {
if (webView.loadProgress === 100) {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";")
}
}
onIsPlayingChanged: {
if (webView.loadProgress === 100) {
if (isPlaying === "false") {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();")
} else {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.pause();")
}
}
}
}
WebEngineView {
id: webView
anchors.fill: parent
url: Qt.resolvedUrl("file:///" + mainwindow.getApplicationPath() + "/index.html")
url: Qt.resolvedUrl("file:///" + mainwindow.getApplicationPath(
) + "/index.html")
onLoadProgressChanged: {
print(loadProgress)
if (loadProgress === 100) {
runJavaScript("var videoPlayer = document.getElementById('videoPlayer');
runJavaScript(("
var videoPlayer = document.getElementById('videoPlayer');
var videoSource = document.getElementById('videoSource');
videoSource.src = \"file:///" + mainwindow.fullContentPath + "\";
videoPlayer.load();", function(result) { mainwindow.init(); timer.start()});
videoPlayer.load();
videoPlayer.volume = " + mainwindow.volume + ";"),
function (result) {
mainwindow.init()
timer.start()
})
}
}
onJavaScriptConsoleMessage: print(message)
settings.allowRunningInsecureContent: true
}
Timer {
id: timer
interval: 200
@ -99,5 +90,4 @@ Rectangle {
duration: 300
}
}
}

View File

@ -19,6 +19,7 @@ BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder, QString volume, QString fillmode, QScreen* parent)
: QWindow(parent)
{
#ifdef Q_OS_WIN
setOpacity(0);
@ -45,7 +46,7 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
if (!m_project.contains("type")) {
if (m_project.contains("file")) {
QString fileEnding = m_project.value("file").toString();
if (fileEnding.endsWith(".mp4") || fileEnding.endsWith(".vp9") || fileEnding.endsWith(".webm")) {
if (fileEnding.endsWith(".webm")) {
m_project.insert("type", "video");
}
}
@ -102,7 +103,6 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
}
//Hide first to avoid flickering
ShowWindow(m_worker_hwnd, SW_HIDE);
ShowWindow(m_hwnd, SW_HIDE);
MoveWindow(m_hwnd, screen->geometry().x() + offsetX, screen->geometry().y() + offsetY, screen->size().width(), screen->size().height(), true);
@ -122,7 +122,6 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
m_quickRenderer.data()->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
m_quickRenderer.data()->show();
setDecoder(decoder);
setVolume(volume.toFloat());
setFillMode(fillmode);
@ -132,7 +131,6 @@ MainWindow::MainWindow(int i, QString projectPath, QString id, QString decoder,
}
});
#endif
}
void MainWindow::init()
@ -152,21 +150,33 @@ void MainWindow::setScreenNumber(const QVector<int>& screenNumber)
{
m_screenNumber = screenNumber;
}
void MainWindow::connected()
{
}
void MainWindow::disconnected()
{
}
void MainWindow::bytesWritten(qint64 bytes)
{
}
void MainWindow::readyRead()
{
}
void MainWindow::error(QLocalSocket::LocalSocketError socketError)
{
}
void MainWindow::destroyThis()
{
QPropertyAnimation* animation = new QPropertyAnimation(this, "opacity");
animation->setDuration(500);
animation->setStartValue(1);
animation->setEndValue(0);
animation->start();
QObject::connect(animation, &QPropertyAnimation::finished, [&]() {
#ifdef Q_OS_WIN
ShowWindow(m_worker_hwnd, SW_HIDE);
ShowWindow(m_hwnd, SW_HIDE);
#endif
QCoreApplication::quit();
});
}
QUrl MainWindow::projectPath() const

View File

@ -5,6 +5,7 @@
#include <QEasingCurve>
#include <QJsonDocument>
#include <QJsonObject>
#include <QLocalSocket>
#include <QObject>
#include <QPropertyAnimation>
#include <QQmlContext>
@ -12,14 +13,15 @@
#include <QScreen>
#include <QSharedPointer>
#include <QWindow>
#include <QtGlobal>
#include <QtQuick/QQuickView>
#include <QtQuick/QQuickWindow>
#include <QtGlobal>
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif
class MainWindow : public QWindow {
Q_OBJECT
@ -27,25 +29,22 @@ public:
explicit MainWindow(int i, QString projectPath, QString id, QString decoder, QString volume, QString fillmode, QScreen* parent = nullptr);
~MainWindow();
Q_PROPERTY(QVector<int> screenNumber READ screenNumber WRITE setScreenNumber NOTIFY screenNumberChanged)
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
Q_PROPERTY(QString appID READ name WRITE setname NOTIFY nameChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
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)
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
QString projectConfig() const
{
return m_projectConfig;
}
QString name() const
{
return m_appID;
@ -66,8 +65,6 @@ public:
void setScreenNumber(const QVector<int>& screenNumber);
QString fillMode() const
{
return m_fillMode;
@ -83,17 +80,21 @@ public:
return m_volume;
}
QString decoder() const
{
return m_decoder;
}
QString fullContentPath() const
{
return m_fullContentPath;
}
bool isPlaying() const
{
return m_isPlaying;
}
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void readyRead();
void error(QLocalSocket::LocalSocketError socketError);
void destroyThis();
void init();
@ -106,7 +107,6 @@ public slots:
emit projectConfigChanged(m_projectConfig);
}
void setname(QString appID)
{
if (m_appID == appID)
@ -153,15 +153,6 @@ public slots:
emit volumeChanged(m_volume);
}
void setDecoder(QString decoder)
{
if (m_decoder == decoder)
return;
m_decoder = decoder;
emit decoderChanged(m_decoder);
}
QString getApplicationPath();
void setFullContentPath(QString fullContentPath)
@ -173,6 +164,15 @@ public slots:
emit fullContentPathChanged(m_fullContentPath);
}
void setIsPlaying(bool isPlaying)
{
if (m_isPlaying == isPlaying)
return;
m_isPlaying = isPlaying;
emit isPlayingChanged(m_isPlaying);
}
signals:
void playVideo(QString path);
void playQmlScene(QString file);
@ -183,10 +183,10 @@ signals:
void fillModeChanged(QString fillMode);
void loopsChanged(bool loops);
void volumeChanged(float volume);
void decoderChanged(QString decoder);
void fullContentPathChanged(QString fullContentPath);
void isPlayingChanged(bool isPlaying);
private:
#ifdef Q_OS_WIN
HWND m_hwnd;
@ -197,6 +197,7 @@ private:
QString m_projectFile;
QJsonObject m_project;
QString m_projectConfig;
QSharedPointer<QLocalSocket> m_socket;
QString m_appID;
QVector<int> m_screenNumber;
@ -204,6 +205,6 @@ private:
QString m_fillMode;
bool m_loops;
float m_volume;
QString m_decoder;
QString m_fullContentPath;
bool m_isPlaying;
};