1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/ScreenPlayWindow/main.qml

137 lines
3.9 KiB
QML
Raw Normal View History

import QtQuick 2.9
import QtWebEngine 1.7
Rectangle {
2018-03-12 15:23:03 +01:00
id: root
anchors.fill: parent
2018-02-23 11:56:36 +01:00
2018-02-14 10:21:15 +01:00
Connections {
target: mainwindow
2018-09-20 15:44:29 +02:00
2018-09-21 16:25:31 +02:00
onQmlExit: {
2018-09-20 15:44:29 +02:00
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
mainwindow.destroyThis()
}
onFillModeChanged: {
2018-09-21 16:25:31 +02:00
//TODO
}
2018-09-08 13:46:31 +02:00
onQmlSceneValueReceived: {
var obj2 = 'import QtQuick 2.9; Item {Component.onCompleted: loader.item.'
+ key + ' = ' + value + '; }'
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
newObject.destroy(10000)
}
onLoopsChanged: {
if (webView.loadProgress === 100) {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.loop = " + loops + ";")
}
2018-09-06 15:54:55 +02:00
}
onVolumeChanged: {
2018-09-06 13:57:36 +02:00
if (webView.loadProgress === 100) {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";")
}
}
onPlaybackRateChanged: {
if (webView.loadProgress === 100) {
webView.runJavaScript(
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.playbackRate = " + playbackRate + ";")
}
}
2018-09-06 13:57:36 +02:00
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();")
}
}
}
}
2018-02-23 11:56:36 +01:00
2018-09-06 15:54:55 +02:00
Component.onCompleted: {
if (mainwindow.type === "qmlScene") {
loader.setSource(Qt.resolvedUrl(
"file:///" + mainwindow.fullContentPath))
mainwindow.init()
timer.start()
} else if (mainwindow.type === "video") {
webView.visible = true
webView.url = Qt.resolvedUrl(
"file:///" + mainwindow.getApplicationPath(
) + "/index.html")
2018-09-21 16:25:31 +02:00
} else if (mainwindow.type === "html") {
webView.visible = true
webView.url = Qt.resolvedUrl(
"file:///" + mainwindow.fullContentPath)
mainwindow.init()
timer.start()
2018-09-06 15:54:55 +02:00
}
}
WebEngineView {
id: webView
2018-02-23 11:56:36 +01:00
anchors.fill: parent
2018-09-06 15:54:55 +02:00
visible: false
onLoadProgressChanged: {
if (loadProgress === 100) {
2018-09-06 13:57:36 +02:00
runJavaScript(("
2018-09-06 15:54:55 +02:00
var videoPlayer = document.getElementById('videoPlayer');
var videoSource = document.getElementById('videoSource');
videoSource.src = \"file:///" + mainwindow.fullContentPath + "\";
videoPlayer.load();
videoPlayer.volume = " + mainwindow.volume + ";"), function (result) {
mainwindow.init()
timer.start()
})
}
}
2018-08-25 00:43:23 +02:00
onJavaScriptConsoleMessage: print(message)
settings.allowRunningInsecureContent: true
2018-03-12 15:23:03 +01:00
}
2018-09-06 13:57:36 +02:00
2018-09-06 15:54:55 +02:00
Loader {
id: loader
anchors.fill: parent
onStatusChanged: {
print(webViewWrapper.errorString())
}
}
Timer {
2018-09-06 13:57:36 +02:00
id: timer
2018-08-25 00:43:23 +02:00
interval: 200
onTriggered: {
2018-08-25 00:43:23 +02:00
anim.start()
}
}
Rectangle {
2018-09-06 13:57:36 +02:00
id: curtain
2018-08-25 00:43:23 +02:00
anchors.fill: parent
color: "black"
PropertyAnimation {
2018-09-06 13:57:36 +02:00
id: anim
2018-08-25 00:43:23 +02:00
property: "opacity"
target: curtain
from: "1"
to: "0"
duration: 300
2018-03-12 15:23:03 +01:00
}
2018-02-23 11:56:36 +01:00
}
}