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

Add fade in and out transitions

This commit is contained in:
kelteseth 2018-02-18 17:02:03 +01:00
parent c9522fba52
commit c6694afa1a
4 changed files with 54 additions and 104 deletions

View File

@ -8,72 +8,27 @@ Rectangle {
property string videoPath
onVideoPathChanged: {
player.source = Qt.resolvedUrl("file:///" + videoPath)
print("######### " + player.source)
state = "playing"
player.play()
}
property bool isPlaying: true
// onIsPlayingChanged: {
// if(isPlaying){
// player.play()
// state = "playing"
// } else {
// player.pause()
// state = ""
// }
// }
// Connections{
// target: wallpaper
// onPrepareDestroy:{
// player.stop();
// wallpaper.destroyWindow()
// }
// onVolumeChanged:{
// player.volume = wallpaper.volume
// }
// onIsPlayingChanged:{
// if(wallpaper.isPlaying){
// player.play()
// } else {
// player.pause()
// }
// }
// onDecoderChanged:{
// player.videoCodecPriority = [decoder]
// }
// onFillModeChanged:{
// if(fillMode === "Stretch"){
// videoOut.fillMode = VideoOutput2.Stretch
// } else if(fillMode === "PreserveAspectFit"){
// videoOut.fillMode = VideoOutput2.PreserveAspectFit
// }else if(fillMode === "PreserveAspectCrop"){
// videoOut.fillMode = VideoOutput2.PreserveAspectCrop
// }
// }
// }
VideoOutput2 {
id: videoOut
anchors.fill: parent
source: player
opacity: 0
opengl: true
fillMode: VideoOutput.Stretch
}
MediaPlayer {
id: player
videoCodecPriority: ["CUDA", "VAAPI", "D3D11", "DXVA", "FFmpeg"]
loops: MediaPlayer.Infinite
volume: 0
onStatusChanged: {
print("STATUS: " + player.status)
if(player.status === MediaPlayer.Loaded){
print("init")
if (player.status === MediaPlayer.Loaded) {
state = "playing"
mainwindow.init()
}
}
@ -82,31 +37,40 @@ Rectangle {
states: [
State {
name: "playing"
PropertyChanges {
target: videoOut
opacity: 1
}
PropertyChanges {
target: player
volume: 1
}
},
State {
name: "destroy"
PropertyChanges {
target: player
volume: 0
}
}
]
transitions: [
Transition {
from: ""
from: "*"
to: "playing"
reversible: true
OpacityAnimator {
target: videoOut
duration: 300
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: player
property: "volume"
duration: 300
duration: 1000
}
},
Transition {
from: "playing"
to: "destroy"
reversible: true
NumberAnimation {
target: player
property: "volume"
duration: 450
}
}
]

View File

@ -24,7 +24,6 @@ int main(int argc, char* argv[])
}
MainWindow w(monitor,argumentList.at(2));
//MainWindow w(0,"D:/672870/786361026");
return a.exec();
}

View File

@ -1,35 +1,29 @@
import QtQuick 2.9
//import net.aimber.screenplaysdk 1.0
import net.aimber.screenplaysdk 1.0
Rectangle {
color: "gray"
anchors.fill: parent
property string tmpVideoPath
// ScreenPlaySDK {
// contentType: "wallpaper"
ScreenPlaySDK {
contentType: "wallpaper"
// onIncommingMessageError: {
// name.text = msg
// }
onIncommingMessageError: {
//name.text = msg
}
// onSdkConnected: {
// name.text = "connected"
// }
onSdkConnected: {
//name.text = "connected"
}
// onSdkDisconnected: {
// name.text = "disconnected"
// mainwindow.destroyThis()
// }
// }
onSdkDisconnected: {
//name.text = "disconnected"
screenVideo.state = "destroy"
mainwindow.destroyThis()
}
}
// Text {
// id: name
// text: qsTr("text")
// anchors.centerIn: parent
// font.pixelSize: 64
// color: "orange"
// }
Connections {
target: mainwindow
@ -38,8 +32,6 @@ Rectangle {
}
}
ScreenVideo {
id:screenVideo
}

View File

@ -102,30 +102,33 @@ MainWindow::MainWindow(int i, QString projectPath, QScreen* parent)
m_quickRenderer.data()->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_quickRenderer.data()->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
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;
}
}
}
void MainWindow::init()
{
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
m_quickRenderer.data()->show();
this->setVisible(true);
setOpacity(0);
QPropertyAnimation* animation = new QPropertyAnimation(this, "opacity");
animation->setDuration(250);
animation->setEasingCurve(QEasingCurve::OutCubic);
animation->setStartValue(0);
animation->setEndValue(1);
animation->start();
QObject::connect(animation, &QPropertyAnimation::finished, [&]() {
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;
}
}
});
}
void MainWindow::destroyThis()
{
QPropertyAnimation* animation = new QPropertyAnimation(this, "opacity");
animation->setDuration(5000);
animation->setDuration(500);
animation->setStartValue(1);
animation->setEndValue(0);
animation->start();
@ -137,14 +140,6 @@ void MainWindow::destroyThis()
});
}
void MainWindow::init()
{
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
m_quickRenderer.data()->show();
this->show();
}
QUrl MainWindow::projectPath() const
{
return m_projectPath;