stop function
This commit is contained in:
parent
10bbbb2f82
commit
cb0272b790
@ -50,6 +50,7 @@ async fn main() {
|
|||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", routing::get(home))
|
.route("/", routing::get(home))
|
||||||
.route("/play/:hash", routing::get(play_handler))
|
.route("/play/:hash", routing::get(play_handler))
|
||||||
|
.route("/stop", routing::get(stop_handler))
|
||||||
.with_state(state);
|
.with_state(state);
|
||||||
|
|
||||||
println!("listening on {}", addr);
|
println!("listening on {}", addr);
|
||||||
@ -89,7 +90,13 @@ async fn play_handler(
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.send(vbplay::Command::Play(full_file_name.into()))
|
.send(vbplay::Command::Play(full_file_name.into()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
//play_clip(&clip.full_file_name());
|
|
||||||
}
|
}
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn stop_handler(state: State<AppState>) -> String {
|
||||||
|
let player = state.player.clone();
|
||||||
|
player.lock().unwrap().send(vbplay::Command::Stop).unwrap();
|
||||||
|
|
||||||
|
"".to_owned()
|
||||||
|
}
|
||||||
|
@ -6,11 +6,17 @@
|
|||||||
function play(hash) {
|
function play(hash) {
|
||||||
fetch("/play/" + hash);
|
fetch("/play/" + hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
fetch("/stop");
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% for clip in clips %}
|
{% for clip in clips %}
|
||||||
<button onclick="play('{{clip.hash}}')">{{clip.file_name}}</button><br />
|
<button onclick="play('{{clip.hash}}')">{{clip.file_name}}</button><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
<button onclick="stop()">Stop.</button>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user