fixing more of the VideoEditor

This commit is contained in:
Chris Cochrun 2024-09-14 06:23:20 -05:00
parent c5ed583522
commit 433ccf345b
5 changed files with 60 additions and 24 deletions

View file

@ -5,6 +5,7 @@ import org.kde.kirigami 2.13 as Kirigami
import QtMultimedia
import "./" as Presenter
import org.presenter 1.0
import mpv 1.0
Item {
id: root
@ -89,10 +90,20 @@ Item {
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
Image {
width: parent.width
height: parent.height
source: video.filePath.toString()
// Need to create the thumbnail for videos as in the library
// and then save them for having a thumbnail here
}
Video {
id: videoPreview
width: parent.width
height: parent.height
source: root.video.filePath.toString()
loops: video.loop ? MediaPlayer.Infinite : 1
}
RowLayout {
@ -107,7 +118,7 @@ Item {
color: Kirigami.Theme.textColor
MouseArea {
anchors.fill: parent
onPressed: videoPreview.playPause()
onPressed: videoPreview.playbackState == MediaPlayer.PlayingState ? videoPreview.pause() : videoPreview.play()
cursorShape: Qt.PointingHandCursor
}
}
@ -124,7 +135,16 @@ Item {
Controls.Label {
id: videoTime
text: new Date(videoPreview.position * 1000).toISOString().slice(11, 19);
text: {
let mil = Math.floor(videoPreview.position);
let sec = Math.floor((mil / 1000) % 60);
let min = Math.floor((mil / (1000 * 60)) % 60);
let hour = Math.floor((mil / (1000 * 60 * 60)) % 24);
sec = (sec < 10) ? "0" + sec : sec;
min = (min < 10) ? "0" + min : min;
hour = (hour < 10) ? "0" + hour : hour;
return hour + ":" + min + ":" + sec
}
}
}
}
@ -217,7 +237,17 @@ Item {
Controls.TextField {
id: endTimeField
Layout.preferredWidth: Kirigami.Units.gridUnit * 6
text: new Date(videoLengthSlider.secondVisualPosition * 1000).toISOString().slice(11, 19);
text: {
let mil = Math.floor(videoLengthSlider.secondVisualPosition);
let sec = Math.floor((mil / 1000) % 60);
let min = Math.floor((mil / (1000 * 60)) % 60);
let hour = Math.floor((mil / (1000 * 60 * 60)) % 24);
sec = (sec < 10) ? "0" + sec : sec;
min = (min < 10) ? "0" + min : min;
hour = (hour < 10) ? "0" + hour : hour;
return hour + ":" + min + ":" + sec
}
horizontalAlignment: TextInput.AlignHCenter
background: Presenter.TextBackground {
control: endTimeField
@ -236,19 +266,20 @@ Item {
}
Timer {
id: mpvLoadingTimer
interval: 100
interval: 500
onTriggered: {
videoPreview.loadFile(video.filePath.toString());
videoPreview.pause();
}
}
function changeVideo(index) {
let vid = videoProxyModel.getVideo(index);
let vid = videoModel.getItem(index);
root.video = vid;
console.log(video.startTime);
console.log(video.endTime);
console.log(vid.startTime);
console.log(vid.endTime);
/* videoPreview.play(); */
mpvLoadingTimer.restart();
footerSecondText = video.filePath;
footerSecondText = vid.filePath;
footerFirstText = "File path: ";
}
@ -259,24 +290,24 @@ Item {
}
function updateEndTime(value) {
videoProxyModel.videoModel.updateEndTime(video.id, Math.min(value, videoPreview.duration));
video.endTime = value;
videoModel.updateEndTime(video.id, Math.min(value, videoPreview.duration));
}
function updateStartTime(value) {
videoProxyModel.videoModel.updateStartTime(video.id, Math.max(value, 0));
video.startTime = value;
videoModel.updateStartTime(video.id, Math.max(value, 0));
}
function updateTitle(text) {
changeTitle(text, false);
videoProxyModel.videoModel.updateTitle(video.id, text);
videoModel.updateTitle(video.id, text);
/* showPassiveNotification(video.title); */
}
function updateLoop(value) {
/* changeStartTime(value, false); */
let bool = videoProxyModel.videoModel.updateLoop(video.id, value);
let bool = videoModel.updateLoop(video.id, value);
if (bool)
video.loop = value;
/* showPassiveNotification("Loop changed to: " + video.loop); */