mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add on the fly decoder switch
This commit is contained in:
parent
8d881f2439
commit
e5c8c4924e
@ -76,6 +76,7 @@
|
||||
<file>qml/Workshop/WorkshopBanner.qml</file>
|
||||
<file>qml/Workshop/WorkshopItem.qml</file>
|
||||
<file>assets/images/missingPreview.png</file>
|
||||
<file>qml/Screens/ScreenVideoPlayer.qml</file>
|
||||
<file>qml/Settings/SettingsButton.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -1,81 +1,18 @@
|
||||
import QtQuick 2.9
|
||||
import QtAV 1.7
|
||||
|
||||
|
||||
Rectangle {
|
||||
id:screenVideo
|
||||
id: screenVideo
|
||||
color: "gray"
|
||||
|
||||
Connections{
|
||||
target: wallpaper
|
||||
onVolumeChanged:{
|
||||
player.volume = wallpaper.volume
|
||||
print(player.volume)
|
||||
}
|
||||
onIsPlayingChanged:{
|
||||
if(wallpaper.isPlaying){
|
||||
player.play()
|
||||
} else {
|
||||
player.pause()
|
||||
}
|
||||
}
|
||||
ScreenVideoPlayer {
|
||||
id: screenVideoPlayer
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
player.source = Qt.resolvedUrl("file:///" + wallpaper.absoluteFilePath)
|
||||
print("AAAA",Qt.resolvedUrl("file:///" + wallpaper.absoluteFilePath))
|
||||
player.play()
|
||||
}
|
||||
|
||||
VideoOutput2 {
|
||||
id: videoOut
|
||||
anchors.fill: parent
|
||||
source: player
|
||||
fillMode: VideoOutput.Stretch
|
||||
}
|
||||
|
||||
MediaPlayer {
|
||||
id: player
|
||||
onPlaying: screenVideo.state = "playing"
|
||||
videoCodecPriority: ["CUDA","FFmpeg", "D3D11", "DXVA", "VAAPI"] //,
|
||||
loops: MediaPlayer.Infinite
|
||||
volume: 0
|
||||
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: curtain
|
||||
anchors.fill: parent
|
||||
color: "black"
|
||||
opacity: 1
|
||||
z:99
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "playing"
|
||||
PropertyChanges {
|
||||
target: curtain
|
||||
opacity:0
|
||||
}
|
||||
PropertyChanges {
|
||||
target: player
|
||||
volume: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
from: ""
|
||||
to: "playing"
|
||||
|
||||
OpacityAnimator {
|
||||
target: curtain
|
||||
duration: 500
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation{
|
||||
target: player
|
||||
property: "volume"
|
||||
duration: 500
|
||||
}
|
||||
}
|
||||
]
|
||||
// Rectangle {
|
||||
// anchors.centerIn: parent
|
||||
// width:400
|
||||
// height:400
|
||||
// color: "red"
|
||||
// }
|
||||
// Component.onCompleted: wallpaper.setupWindow()
|
||||
}
|
||||
|
85
qml/Screens/ScreenVideoPlayer.qml
Normal file
85
qml/Screens/ScreenVideoPlayer.qml
Normal file
@ -0,0 +1,85 @@
|
||||
import QtQuick 2.9
|
||||
import QtAV 1.7
|
||||
|
||||
Rectangle {
|
||||
color: "black"
|
||||
id: screenVideoPlayer
|
||||
anchors.fill: parent
|
||||
property string videoPath
|
||||
property bool isPlaying: false
|
||||
onIsPlayingChanged: {
|
||||
if(isPlaying){
|
||||
player.play()
|
||||
} else {
|
||||
player.pause()
|
||||
}
|
||||
}
|
||||
|
||||
Connections{
|
||||
target: wallpaper
|
||||
onVolumeChanged:{
|
||||
player.volume = wallpaper.volume
|
||||
}
|
||||
onIsPlayingChanged:{
|
||||
if(wallpaper.isPlaying){
|
||||
player.play()
|
||||
} else {
|
||||
player.pause()
|
||||
}
|
||||
}
|
||||
onDecoderChanged:{
|
||||
player.videoCodecPriority = [decoder]
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
player.source = Qt.resolvedUrl("file:///" + wallpaper.absoluteFilePath)
|
||||
player.play()
|
||||
screenVideoPlayer.state = "playing"
|
||||
}
|
||||
|
||||
VideoOutput2 {
|
||||
id: videoOut
|
||||
anchors.fill: parent
|
||||
source: player
|
||||
opacity: 0
|
||||
fillMode: VideoOutput.Stretch
|
||||
}
|
||||
|
||||
MediaPlayer {
|
||||
id: player
|
||||
videoCodecPriority: ["CUDA", "VAAPI", "D3D11", "DXVA", "FFmpeg"]
|
||||
loops: MediaPlayer.Infinite
|
||||
volume: 0
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "playing"
|
||||
PropertyChanges {
|
||||
target: videoOut
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges {
|
||||
target: player
|
||||
volume: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
from: ""
|
||||
to: "playing"
|
||||
|
||||
OpacityAnimator {
|
||||
target: videoOut
|
||||
duration: 300
|
||||
easing.type: Easing.InOutQuad
|
||||
}
|
||||
NumberAnimation {
|
||||
target: player
|
||||
property: "volume"
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -199,7 +199,9 @@ public slots:
|
||||
return;
|
||||
|
||||
m_decoder = decoder;
|
||||
qDebug() << m_decoder;
|
||||
for (int i = 0; i < m_wallpapers.size(); ++i) {
|
||||
m_wallpapers.at(i).data()->setDecoder(decoder);
|
||||
}
|
||||
emit decoderChanged(m_decoder);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "wallpaper.h"
|
||||
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
|
||||
{
|
||||
// 0xXXXXXXX "" WorkerW
|
||||
@ -18,21 +20,21 @@ Wallpaper::Wallpaper(QWindow* parent)
|
||||
{
|
||||
}
|
||||
|
||||
Wallpaper::Wallpaper( ProjectFile project, Monitor monitor)
|
||||
Wallpaper::Wallpaper(ProjectFile project, Monitor monitor)
|
||||
{
|
||||
m_monitor = monitor;
|
||||
m_project = project;
|
||||
QString tmp = m_project.m_absoluteStoragePath.toString() + "/" + m_project.m_file.toString();
|
||||
tmp.replace("/","\\\\");
|
||||
tmp.replace("/", "\\\\");
|
||||
setAbsoluteFilePath(tmp);
|
||||
|
||||
this->setX(m_monitor.m_geometry.x());
|
||||
this->setY(m_monitor.m_geometry.y());
|
||||
this->setWidth(m_monitor.m_geometry.width());
|
||||
this->setHeight(m_monitor.m_geometry.height());
|
||||
this->setX(m_monitor.m_availableGeometry.x());
|
||||
this->setY(m_monitor.m_availableGeometry.y());
|
||||
this->setWidth(m_monitor.m_availableGeometry.width());
|
||||
this->setHeight(m_monitor.m_availableGeometry.height());
|
||||
this->m_hwnd = (HWND)this->winId();
|
||||
|
||||
qDebug() << "++++"<< this->x() << this->y() << this->width() << this->height();
|
||||
|
||||
HWND progman_hwnd = FindWindowW(L"Progman", L"Program Manager");
|
||||
|
||||
// Spawn new worker window below desktop (using some undocumented Win32 magic)
|
||||
@ -44,27 +46,39 @@ Wallpaper::Wallpaper( ProjectFile project, Monitor monitor)
|
||||
1000, nullptr);
|
||||
|
||||
EnumWindows(SearchForWorkerWindow, reinterpret_cast<LPARAM>(&m_worker_hwnd));
|
||||
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
|
||||
|
||||
SetParent(m_hwnd, m_worker_hwnd);
|
||||
SetLayeredWindowAttributes(m_hwnd,RGB(255,0,0),0,LWA_ALPHA);
|
||||
SetWindowLongPtr(m_hwnd, GWL_STYLE,
|
||||
WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
|
||||
SetWindowLongPtr(m_hwnd, GWL_EXSTYLE,
|
||||
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOACTIVATE | WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW);
|
||||
|
||||
Qt::WindowFlags flags = this->flags();
|
||||
this->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
|
||||
this->show();
|
||||
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
|
||||
m_quickRenderer = new QQuickView(this);
|
||||
m_quickRenderer->setWidth(this->width());
|
||||
m_quickRenderer->setHeight(this->height());
|
||||
m_context = m_quickRenderer->rootContext();
|
||||
m_context->setContextProperty("wallpaper", this);
|
||||
m_quickRenderer->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||
|
||||
m_quickRenderer->setSource(QUrl("qrc:/qml/Components/Screens/ScreenVideo.qml"));
|
||||
m_quickRenderer->show();
|
||||
this->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
|
||||
// this->setOpacity(0.0f);
|
||||
this->show();
|
||||
|
||||
|
||||
m_quickRenderer = QSharedPointer<QQuickView>(new QQuickView(this));
|
||||
|
||||
// QSurfaceFormat surfaceFormat;
|
||||
// surfaceFormat.setAlphaBufferSize(8);
|
||||
// surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
// m_quickRenderer.data()->setFormat(surfaceFormat);
|
||||
|
||||
//m_quickRenderer.data()->setColor(QColor(Qt::transparent));
|
||||
m_quickRenderer.data()->setWidth(this->width());
|
||||
m_quickRenderer.data()->setHeight(this->height());
|
||||
//m_quickRenderer.data()->setClearBeforeRendering(true);
|
||||
|
||||
m_context = m_quickRenderer.data()->rootContext();
|
||||
m_context->setContextProperty("wallpaper", this);
|
||||
m_quickRenderer.data()->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||
m_quickRenderer.data()->setSource(QUrl("qrc:/qml/Screens/ScreenVideo.qml"));
|
||||
m_quickRenderer.data()->showFullScreen();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
Wallpaper::~Wallpaper()
|
||||
@ -76,6 +90,15 @@ Wallpaper::~Wallpaper()
|
||||
DestroyWindow(m_hwnd);
|
||||
}
|
||||
|
||||
void Wallpaper::setupWindow()
|
||||
{
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(this, "opacity");
|
||||
anim->setDuration(2000);
|
||||
anim->setStartValue(0);
|
||||
anim->setEndValue(1);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
Monitor Wallpaper::monitor() const
|
||||
{
|
||||
return m_monitor;
|
||||
@ -83,13 +106,17 @@ Monitor Wallpaper::monitor() const
|
||||
|
||||
void Wallpaper::setVisible(bool visible)
|
||||
{
|
||||
if (visible)
|
||||
if (visible){
|
||||
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
|
||||
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
|
||||
else
|
||||
}
|
||||
else{
|
||||
ShowWindow(m_worker_hwnd, SW_HIDE);
|
||||
ShowWindow(m_hwnd, SW_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::setMonitor(const Monitor &monitor)
|
||||
void Wallpaper::setMonitor(const Monitor& monitor)
|
||||
{
|
||||
m_monitor = monitor;
|
||||
}
|
||||
|
@ -1,29 +1,37 @@
|
||||
#ifndef WALLPAPER_H
|
||||
#define WALLPAPER_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickView>
|
||||
#include <QRect>
|
||||
#include <QSharedPointer>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QUrl>
|
||||
#include <QWindow>
|
||||
#include <qt_windows.h>
|
||||
#include <QUrl>
|
||||
#include <QDir>
|
||||
|
||||
#include "monitorlistmodel.h"
|
||||
#include "profile.h"
|
||||
#include "projectfile.h"
|
||||
#include "monitorlistmodel.h"
|
||||
|
||||
class Wallpaper : public QWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Wallpaper(QWindow* parent = 0);
|
||||
Wallpaper( ProjectFile project, Monitor monitor);
|
||||
Wallpaper(ProjectFile project, Monitor monitor);
|
||||
~Wallpaper();
|
||||
|
||||
Q_PROPERTY(QString absoluteFilePath READ absoluteFilePath WRITE setAbsoluteFilePath NOTIFY absoluteFilePathChanged)
|
||||
Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged)
|
||||
Q_PROPERTY(bool isPlaying READ isPlaying WRITE setIsPlaying NOTIFY isPlayingChanged)
|
||||
Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(float opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
|
||||
|
||||
Q_INVOKABLE void setupWindow();
|
||||
|
||||
QString absoluteFilePath() const
|
||||
{
|
||||
@ -37,13 +45,23 @@ public:
|
||||
|
||||
Monitor monitor() const;
|
||||
|
||||
void setMonitor(const Monitor &monitor);
|
||||
void setMonitor(const Monitor& monitor);
|
||||
|
||||
float volume() const
|
||||
{
|
||||
return m_volume;
|
||||
}
|
||||
|
||||
float opacity() const
|
||||
{
|
||||
return m_opacity;
|
||||
}
|
||||
|
||||
QString decoder() const
|
||||
{
|
||||
return m_decoder;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setAbsoluteFilePath(QString absoluteFilePath)
|
||||
{
|
||||
@ -75,17 +93,38 @@ public slots:
|
||||
emit volumeChanged(m_volume);
|
||||
}
|
||||
|
||||
void setOpacity(float opacity)
|
||||
{
|
||||
qDebug() << opacity;
|
||||
//this->setOpacity(opacity);
|
||||
qWarning("Floating point comparison needs context sanity check");
|
||||
if (qFuzzyCompare(m_opacity, opacity))
|
||||
return;
|
||||
|
||||
m_opacity = opacity;
|
||||
emit opacityChanged(m_opacity);
|
||||
}
|
||||
|
||||
void setDecoder(QString decoder)
|
||||
{
|
||||
if (m_decoder == decoder)
|
||||
return;
|
||||
|
||||
m_decoder = decoder;
|
||||
emit decoderChanged(m_decoder);
|
||||
}
|
||||
|
||||
signals:
|
||||
void absoluteFilePathChanged(QString absoluteFilePath);
|
||||
|
||||
void isPlayingChanged(bool isPlaying);
|
||||
|
||||
void volumeChanged(float volume);
|
||||
void opacityChanged(float opacity);
|
||||
void decoderChanged(QString decoder);
|
||||
|
||||
private:
|
||||
HWND m_hwnd;
|
||||
HWND m_worker_hwnd;
|
||||
QQuickView* m_quickRenderer = nullptr;
|
||||
QSharedPointer<QQuickView> m_quickRenderer = nullptr;
|
||||
QQmlContext* m_context = nullptr;
|
||||
|
||||
Profile m_profile;
|
||||
@ -95,6 +134,8 @@ private:
|
||||
|
||||
bool m_isPlaying = true;
|
||||
float m_volume = 1.0f;
|
||||
float m_opacity;
|
||||
QString m_decoder;
|
||||
};
|
||||
|
||||
#endif // WALLPAPER_H
|
||||
|
Loading…
Reference in New Issue
Block a user