mirror of
https://github.com/ayabusa/Rusty-slicer.git
synced 2024-11-22 03:03:24 +00:00
added a progress bar
This commit is contained in:
parent
9f29e6d64c
commit
6ff254ddf4
@ -35,9 +35,9 @@ async fn select_folder_button(app: tauri::AppHandle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn slice_button(app: tauri::AppHandle, chapter: &str){
|
async fn slice_button(app: tauri::AppHandle, chapter: String){
|
||||||
// Try to format the chapters and panic if it was not able to
|
// Try to format the chapters and panic if it was not able to
|
||||||
let formated_chapters = match format_chapter(chapter) {
|
let formated_chapters = match format_chapter(&chapter) {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
Err(error) => panic!("Problem slicing chapter: {:?}", error),
|
Err(error) => panic!("Problem slicing chapter: {:?}", error),
|
||||||
};
|
};
|
||||||
@ -52,6 +52,15 @@ fn slice_button(app: tauri::AppHandle, chapter: &str){
|
|||||||
Err(error) => panic!("Problem creating directory : {:?}", error),
|
Err(error) => panic!("Problem creating directory : {:?}", error),
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
|
// create the progress window
|
||||||
|
let _about_window = tauri::WindowBuilder::new(
|
||||||
|
&app,
|
||||||
|
"progress", /* the unique window label */
|
||||||
|
tauri::WindowUrl::App("progress.html".into())
|
||||||
|
).build().expect("failed to create progress window");
|
||||||
|
_about_window.set_title("Slicing progress").unwrap();
|
||||||
|
_about_window.set_size(Size::Physical(PhysicalSize { width: 400, height: 100 })).unwrap();
|
||||||
|
|
||||||
for i in 0..time_codes.len(){
|
for i in 0..time_codes.len(){
|
||||||
let args: Vec<String>;
|
let args: Vec<String>;
|
||||||
let mut output_file: PathBuf = PathBuf::from(&FOLDER_PATH.lock().unwrap().to_owned());
|
let mut output_file: PathBuf = PathBuf::from(&FOLDER_PATH.lock().unwrap().to_owned());
|
||||||
@ -67,12 +76,20 @@ fn slice_button(app: tauri::AppHandle, chapter: &str){
|
|||||||
time_codes[i+1].to_owned(),
|
time_codes[i+1].to_owned(),
|
||||||
//format!("{:?}", output_file),
|
//format!("{:?}", output_file),
|
||||||
output_file.display().to_string()];
|
output_file.display().to_string()];
|
||||||
}else {
|
}else { // case for the last song
|
||||||
args = vec!["-version".to_owned()];
|
args = vec!["-i".to_owned(),
|
||||||
|
FILE_PATH.lock().unwrap().to_owned(),
|
||||||
|
"-ss".to_owned(),
|
||||||
|
time_codes[i].to_owned(),
|
||||||
|
//format!("{:?}", output_file),
|
||||||
|
output_file.display().to_string()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch the final ffmpeg command
|
// launch the final ffmpeg command
|
||||||
launch_ffmpeg(app.clone(), args);
|
launch_ffmpeg(app.clone(), args);
|
||||||
|
|
||||||
|
// update progress bar on frontend
|
||||||
|
app.emit_all("progress_state_changed", Payload { message: format!("{}", (i+1)*100/time_codes.len()) }).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
const { listen } = window.__TAURI__.event
|
const { listen } = window.__TAURI__.event
|
||||||
|
|
||||||
document.getElementById("fileLocation").innerHTML = "hey";
|
|
||||||
|
|
||||||
// listen for file location from rust backend
|
// listen for file location from rust backend
|
||||||
const unlistenfile = await listen('file_path_changed', (event) => {
|
const unlistenfile = await listen('file_path_changed', (event) => {
|
||||||
document.getElementById("fileLocation").innerHTML = event.payload.message;
|
document.getElementById("fileLocation").innerHTML = event.payload.message;
|
||||||
|
@ -25,7 +25,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<textarea id="chapterList" rows="30">nothing for now</textarea>
|
<textarea id="chapterList" rows="30">
|
||||||
|
0:00 - my first song
|
||||||
|
3:30 - another one
|
||||||
|
13:37 - one more time - Daft punk</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="select-file">
|
<div class="select-file">
|
||||||
|
16
src/progress.html
Normal file
16
src/progress.html
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="stylesheet" href="styles.css" />
|
||||||
|
<script type="module" src="/progress.js" defer></script>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Slicing progress</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<p class="credit" id="progress_label"> Slicing : 0% </p>
|
||||||
|
<div class="progress_center">
|
||||||
|
<progress value="0" max="100" id="progress_bar"></progress>
|
||||||
|
</div>
|
||||||
|
</body>
|
8
src/progress.js
Normal file
8
src/progress.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const { listen } = window.__TAURI__.event
|
||||||
|
|
||||||
|
// listen for progress update from rust backend
|
||||||
|
const unlistenprogress = await listen('progress_state_changed', (event) => {
|
||||||
|
document.getElementById("progress_label").innerHTML = "Slicing : "+event.payload.message+"%";
|
||||||
|
document.getElementById("progress_bar").value = event.payload.message;
|
||||||
|
console.log("changing progress bar state to : ", event.payload.message);
|
||||||
|
})
|
@ -140,3 +140,14 @@ button {
|
|||||||
from { background-position: 0 0, 50px 50px, 50px 0; }
|
from { background-position: 0 0, 50px 50px, 50px 0; }
|
||||||
to { background-position: -100px -100px, -50px -50px, -50px -100px; }
|
to { background-position: -100px -100px, -50px -50px, -50px -100px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress::-moz-progress-bar { background: #d88939; }
|
||||||
|
progress::-webkit-progress-value { background: #d88939; }
|
||||||
|
progress {
|
||||||
|
color: #d88939;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress_center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user