mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 10:42:29 +01:00
Fix local webengine video loading...
When using the index.html from the qrc file we cannot load local content for some reason... Add Windows looping workaround
This commit is contained in:
parent
379d0c998b
commit
8074535cfb
@ -78,4 +78,5 @@ if(WIN32)
|
||||
# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE shcore.lib)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/index.html COPYONLY)
|
||||
endif()
|
||||
|
@ -2,15 +2,43 @@ import QtQuick
|
||||
import QtMultimedia
|
||||
import ScreenPlayWallpaper 1.0
|
||||
|
||||
Video {
|
||||
Item {
|
||||
id: root
|
||||
volume: Wallpaper.volume
|
||||
source: Wallpaper.projectSourceFileAbsolute
|
||||
Component.onCompleted: {
|
||||
root.play()
|
||||
anchors.fill: parent
|
||||
property bool loops: Wallpaper.loops
|
||||
property bool isWindows: Qt.platform === "windows"
|
||||
signal requestFadeIn
|
||||
|
||||
MediaPlayer {
|
||||
id: mediaPlayer
|
||||
|
||||
source: Wallpaper.projectSourceFileAbsolute
|
||||
Component.onCompleted: {
|
||||
mediaPlayer.play()
|
||||
root.requestFadeIn()
|
||||
}
|
||||
loops: !root.isWindows && root.loops ? MediaPlayer.Infinite : 1
|
||||
onPositionChanged: {
|
||||
if (!root.isWindows)
|
||||
return
|
||||
|
||||
if ((mediaPlayer.position >= mediaPlayer.duration) && root.loops) {
|
||||
mediaPlayer.setPosition(0)
|
||||
mediaPlayer.stop()
|
||||
mediaPlayer.play()
|
||||
}
|
||||
}
|
||||
|
||||
videoOutput: vo
|
||||
audioOutput: ao
|
||||
}
|
||||
onStopped: {
|
||||
if (Wallpaper.loops)
|
||||
root.play()
|
||||
VideoOutput {
|
||||
id: vo
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
AudioOutput {
|
||||
id: ao
|
||||
volume: Wallpaper.volume
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,14 @@ import QtWebEngine
|
||||
import ScreenPlay.Enums.InstalledType 1.0
|
||||
import ScreenPlayWallpaper 1.0
|
||||
|
||||
|
||||
/*!
|
||||
* The native macOS multimedia stack does not support VP8/VP9. For this we must use the WebEngine.
|
||||
*/
|
||||
Item {
|
||||
id: root
|
||||
|
||||
signal requestFadeIn()
|
||||
signal requestFadeIn
|
||||
|
||||
function getSetVideoCommand() {
|
||||
// TODO 30:
|
||||
@ -40,14 +41,11 @@ Item {
|
||||
WebEngineView {
|
||||
id: webView
|
||||
anchors.fill: parent
|
||||
// url:"https://www.google.de"
|
||||
url: "qrc:/index.html"
|
||||
onJavaScriptConsoleMessage:(lineNumber, message)=> print(lineNumber, message)
|
||||
url: Wallpaper.getApplicationPath() + "/index.html"
|
||||
onJavaScriptConsoleMessage: (lineNumber, message) => print(lineNumber,
|
||||
message)
|
||||
onLoadProgressChanged: {
|
||||
if (loadProgress === 100) {
|
||||
loadHtml("")
|
||||
requestFadeIn()
|
||||
return
|
||||
webView.runJavaScript(root.getSetVideoCommand(),
|
||||
function (result) {
|
||||
requestFadeIn()
|
||||
@ -56,8 +54,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Text {
|
||||
id: txtVisualsPaused
|
||||
text: qsTr("If you can read this, then the VisualsPaused optimization does not work on your system. You can fix this by disable this in: \n Settings -> Perfromance -> Pause wallpaper video rendering while another app is in the foreground ")
|
||||
|
@ -12,45 +12,43 @@ Rectangle {
|
||||
property bool canFadeByWallpaperFillMode: true
|
||||
|
||||
function init() {
|
||||
print("init")
|
||||
switch (Wallpaper.type) {
|
||||
case InstalledType.VideoWallpaper:
|
||||
if(Wallpaper.videoCodec === VideoCodec.Unknown){
|
||||
if (Wallpaper.videoCodec === VideoCodec.Unknown) {
|
||||
Wallpaper.terminate()
|
||||
}
|
||||
if(Qt.platform.os === "osx") {
|
||||
// macOS only supports h264 via the native Qt MM
|
||||
if(Wallpaper.videoCodec === VideoCodec.VP8 || Wallpaper.videoCodec === VideoCodec.VP9){
|
||||
print(Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute))
|
||||
loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaWebView.qml";
|
||||
print(loader.status)
|
||||
}else {
|
||||
loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml";
|
||||
}
|
||||
// macOS only supports h264 via the native Qt MM
|
||||
if (Wallpaper.videoCodec === VideoCodec.VP8
|
||||
|| Wallpaper.videoCodec === VideoCodec.VP9) {
|
||||
loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaWebView.qml"
|
||||
} else {
|
||||
loader.source = "qrc:/ScreenPlayWallpaper/qml/MultimediaView.qml"
|
||||
}
|
||||
fadeIn();
|
||||
break;
|
||||
break
|
||||
case InstalledType.HTMLWallpaper:
|
||||
loader.setSource("qrc:/ScreenPlayWallpaper/qml/WebView.qml", {
|
||||
"url": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
||||
});
|
||||
break;
|
||||
"url": Qt.resolvedUrl(
|
||||
Wallpaper.projectSourceFileAbsolute)
|
||||
})
|
||||
break
|
||||
case InstalledType.QMLWallpaper:
|
||||
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute);
|
||||
fadeIn();
|
||||
break;
|
||||
loader.source = Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
||||
fadeIn()
|
||||
break
|
||||
case InstalledType.WebsiteWallpaper:
|
||||
loader.setSource("qrc:/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", {
|
||||
"url": Wallpaper.projectSourceFileAbsolute
|
||||
});
|
||||
fadeIn();
|
||||
break;
|
||||
loader.setSource(
|
||||
"qrc:/ScreenPlayWallpaper/qml/WebsiteWallpaper.qml", {
|
||||
"url": Wallpaper.projectSourceFileAbsolute
|
||||
})
|
||||
fadeIn()
|
||||
break
|
||||
case InstalledType.GifWallpaper:
|
||||
loader.setSource("qrc:/ScreenPlayWallpaper/qml/GifWallpaper.qml", {
|
||||
"source": Qt.resolvedUrl(Wallpaper.projectSourceFileAbsolute)
|
||||
});
|
||||
fadeIn();
|
||||
break;
|
||||
"source": Qt.resolvedUrl(
|
||||
Wallpaper.projectSourceFileAbsolute)
|
||||
})
|
||||
fadeIn()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,33 +82,27 @@ BaseWindow::BaseWindow(
|
||||
QApplication::exit(-4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (auto typeOpt = ScreenPlayUtil::getInstalledTypeFromString(project.value("type").toString())) {
|
||||
setType(typeOpt.value());
|
||||
|
||||
if (!project.contains("videoCodec") ) {
|
||||
if (!project.contains("videoCodec")) {
|
||||
qWarning("No videoCodec was specified inside the json object!");
|
||||
// QApplication::exit(-4);
|
||||
const QString filename = project.value("file").toString();
|
||||
qInfo() << filename;
|
||||
if(filename.endsWith(".mp4")){
|
||||
if (filename.endsWith(".mp4")) {
|
||||
setVideoCodec(ScreenPlay::VideoCodec::VideoCodec::H264);
|
||||
} else if(filename.endsWith(".webm")){
|
||||
} else if (filename.endsWith(".webm")) {
|
||||
setVideoCodec(ScreenPlay::VideoCodec::VideoCodec::VP8);
|
||||
}
|
||||
} else {
|
||||
if(this->type() == ScreenPlay::InstalledType::InstalledType::VideoWallpaper){
|
||||
if (this->type() == ScreenPlay::InstalledType::InstalledType::VideoWallpaper) {
|
||||
if (auto videoCodecOpt = ScreenPlayUtil::getVideoCodecFromString(project.value("videoCodec").toString())) {
|
||||
setVideoCodec(videoCodecOpt.value());
|
||||
} else {
|
||||
qCritical() << "Cannot parse Wallpaper video codec from value" << project.value("type");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
qCritical() << "Cannot parse Wallpaper type from value" << project.value("type");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user