some basics of video times - unfinished

This commit is contained in:
Chris Cochrun 2024-04-10 09:49:50 -05:00
parent 0a895e1f04
commit 70040c5149
3 changed files with 23 additions and 17 deletions

View file

@ -62,12 +62,13 @@ Item {
Component.onCompleted: mpvLoadingTimer.start() Component.onCompleted: mpvLoadingTimer.start()
onFileLoaded: { onFileLoaded: {
/* showPassiveNotification(videoSource + " has been loaded"); */ /* showPassiveNotification(videoSource + " has been loaded"); */
if (itemType == "song") if (itemType == "song") {
mpv.setProperty("loop", "inf"); mpv.setProperty("loop", "inf");
else if (vidLoop) } else if (vidLoop) {
mpv.setProperty("loop", "inf"); mpv.setProperty("loop", "inf");
else } else {
mpv.setProperty("loop", "no"); mpv.setProperty("loop", "no");
}
/* showPassiveNotification(mpv.getProperty("loop")); */ /* showPassiveNotification(mpv.getProperty("loop")); */
mpv.setProperty("sid", "no"); mpv.setProperty("sid", "no");
@ -88,6 +89,7 @@ Item {
interval: 100 interval: 100
onTriggered: { onTriggered: {
/* showPassiveNotification("YIPPEEE!") */ /* showPassiveNotification("YIPPEEE!") */
mpv.stop();
if (vidStartTime > 0 && vidStartTime < vidEndTime) { if (vidStartTime > 0 && vidStartTime < vidEndTime) {
/* mpv.seek(vidStartTime); */ /* mpv.seek(vidStartTime); */
let start = "+" + vidStartTime; let start = "+" + vidStartTime;

View file

@ -6,7 +6,7 @@ use std::process::Command;
use std::str; use std::str;
use tracing::debug; use tracing::debug;
pub fn bg_from_video(video: &Path) -> PathBuf { pub async fn bg_from_video(video: &Path) -> PathBuf {
let video = PathBuf::from(video); let video = PathBuf::from(video);
debug!(?video); debug!(?video);
let mut data_dir = dirs::data_local_dir().unwrap(); let mut data_dir = dirs::data_local_dir().unwrap();

View file

@ -318,25 +318,29 @@ impl slide_model::SlideModel {
vector_roles vector_roles
.append(self.get_role(SlideRoles::VideoThumbnail)); .append(self.get_role(SlideRoles::VideoThumbnail));
let model_index = let thread = self.qt_thread();
&self.index(index, 0, &QModelIndex::default()); let model_index = &self.as_ref().index(index, 0, &QModelIndex::default());
if let Some(slide) = if let Some(slide) =
self.as_mut().rust_mut().slides.get_mut(index as usize) self.as_mut().rust_mut().slides.get_mut(index as usize)
{ {
if !slide.video_background.is_empty() { if !slide.video_background.is_empty() {
let runtime = tokio::runtime::Runtime::new().unwrap();
let path = let path =
PathBuf::from(slide.video_background.to_string()); PathBuf::from(slide.video_background.to_string());
runtime.spawn(async move {
let video = ffmpeg::bg_from_video(&path).await;
let video = QString::from( let video = QString::from(
ffmpeg::bg_from_video(&path).to_str().unwrap(), video.to_str().unwrap()
) ).insert(0, &QString::from("file://")).to_owned();
.insert(0, &QString::from("file://"))
.to_owned();
slide.video_thumbnail = video; slide.video_thumbnail = video;
self.as_mut().data_changed( thread.queue(move |mut slide|
slide.as_mut().data_changed(
model_index, model_index,
model_index, model_index,
&vector_roles, &vector_roles,
)
); );
});
} }
} }
true true