MPV is working now

This commit is contained in:
Chris Cochrun 2022-02-18 11:33:22 -06:00
parent 6aab0acd27
commit ef1cb70d10
17 changed files with 1630 additions and 48 deletions

View file

@ -85,6 +85,7 @@ Item {
hoverEnabled: true
onClicked: {
ListView.view.currentIndex = index
song = ListView.view.selected
songTitle = title
songLyrics = lyrics
songAuthor = author

View file

@ -11,7 +11,9 @@ import "./" as Presenter
Controls.Page {
id: mainPage
padding: 0
property url background: ""
property url imageBackground: ""
property url videoBackground: ""
property var song
property string songTitle: ""
property string songLyrics: ""
property string songAuthor: ""
@ -79,27 +81,22 @@ Controls.Page {
}
Presenter.Slide {
id: presentationSlide
imageSource: "../../assets/parallel.jpg"
imageSource: imageBackground
videoSource: videoBackground
}
}
}
FileDialog {
id: fileDialog
id: videoFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Video files (*.mp4 *.mkv *.mov *.wmv *.avi *.MP4 *.MOV *.MKV)",
"Image files (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG)"]
nameFilters: ["Video files (*.mp4 *.mkv *.mov *.wmv *.avi *.MP4 *.MOV *.MKV)"]
onAccepted: {
print("You chose: " + fileDialog.fileUrls);
videoBackground = fileDialog.fileUrl;
print(videoBackground);
str = videoBackground.toString();
if (str.endsWith("mp4"))
videoBackground = fileDialog.fileUrl; print("WE DID IT!!");
imageBackground = ""
videoBackground = videoFileDialog.fileUrls[0]
print("video background = " + videoFileDialog.fileUrl)
}
onRejected: {
print("Canceled")
@ -108,8 +105,20 @@ Controls.Page {
}
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
FileDialog {
id: imageFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Image files (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG)"]
onAccepted: {
videoBackground = ""
imageBackground = imageFileDialog.fileUrls
}
onRejected: {
print("Canceled")
/* Qt.quit() */
}
}
}

View file

@ -1,11 +1,12 @@
import QtQuick 2.13
import QtQuick.Controls 2.15 as Controls
import QtQuick.Layouts 1.2
import QtMultimedia 5.15
/* import QtMultimedia 5.15 */
import QtAudioEngine 1.15
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import mpv 1.0
Item {
id: root
@ -14,32 +15,66 @@ Item {
property real textSize: 50
property bool editMode: false
property bool dropShadow: false
property url imageSource: ""
property url videoSource: ""
property url imageSource: imageBackground
property url videoSource: videoBackground
property string chosenFont: "Quicksand"
property color backgroundColor
Rectangle {
id: basePrColor
anchors.fill: parent
color: "black"
MediaPlayer {
id: videoPlayer
source: videoSource
loops: MediaPlayer.Infinite
autoPlay: true
notifyInterval: 100
/* MediaPlayer { */
/* id: mediaPlayer */
/* source: videoSource */
/* loops: MediaPlayer.Infinite */
/* autoPlay: editMode ? false : true */
/* notifyInterval: 100 */
/* } */
/* VideoOutput { */
/* id: videoPlayer */
/* anchors.fill: parent */
/* source: mediaPlayer */
/* /\* flushMode: VideoOutput.LastFrame *\/ */
/* MouseArea { */
/* id: playArea */
/* anchors.fill: parent */
/* onPressed: mediaPlayer.play(); */
/* } */
/* } */
MpvObject {
id: mpv
objectName: "mpv"
anchors.fill: parent
useHwdec: true
Component.onCompleted: mpvLoadingTimer.start()
onFileLoaded: {
print(videoSource + " has been loaded");
mpv.setProperty("loop", "inf");
print(mpv.getProperty("loop"));
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: mpv.loadFile(videoSource.toString());
}
/* Controls.ProgressBar { */
/* anchors.centerIn: parent */
/* width: parent.width - 400 */
/* value: mpv.position */
/* to: mpv.duration */
/* } */
}
VideoOutput {
id: videoOutput
anchors.fill: parent
source: videoPlayer
}
MouseArea {
id: playArea
anchors.fill: parent
onPressed: videoPlayer.play();
Timer {
id: mpvLoadingTimer
interval: 100
onTriggered: mpv.loadFile(videoSource.toString())
}
Image {
@ -48,13 +83,14 @@ Item {
source: imageSource
fillMode: Image.PreserveAspectCrop
clip: true
visible: false
}
FastBlur {
id: imageBlue
anchors.fill: parent
source: backgroundImage
source: imageSource == "" ? mpv : backgroundImage
radius: blurRadius
Controls.Label {
@ -77,7 +113,6 @@ Item {
color: "#80000000"
visible: true
}
}
}
}

View file

@ -13,6 +13,6 @@ Item {
Presenter.Slide {
id: representation
editMode: true
}
}

View file

@ -55,11 +55,38 @@ Item {
onClicked: {}
}
Controls.ToolButton {
id: backgroundButton
text: "Background"
icon.name: "fileopen"
onClicked: {
print("Action button in buttons page clicked");
fileDialog.open()
onClicked: backgroundType.open()
}
Controls.Popup {
id: backgroundType
x: backgroundButton.x
y: backgroundButton.y + backgroundButton.height + 20
width: 200
height: 100
modal: true
focus: true
dim: false
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
ColumnLayout {
anchors.fill: parent
Controls.ToolButton {
Layout.fillHeight: true
Layout.fillWidth: true
text: "Video"
icon.name: "emblem-videos-symbolic"
onClicked: videoFileDialog.open() & backgroundType.close()
}
Controls.ToolButton {
Layout.fillWidth: true
Layout.fillHeight: true
text: "Image"
icon.name: "folder-pictures-symbolic"
onClicked: imageFileDialog.open() & backgroundType.close()
}
}
}
}
@ -106,7 +133,7 @@ Item {
text: songLyrics
textFormat: TextEdit.MarkdownText
padding: 10
onEditingFinished: editorTimer.running = false
onEditingFinished: song.lyricsSlides(text)
onPressed: editorTimer.running = true
}
}