Add picture of grzeg
This commit is contained in:
parent
5e3df86a2a
commit
6bb8d28eff
Binary file not shown.
After Width: | Height: | Size: 157 KiB |
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use axum::{Router, Server};
|
use axum::{Router, Server};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use mpv_setup::{connect_to_mpv, create_mpv_config_file};
|
use mpv_setup::{connect_to_mpv, create_mpv_config_file, show_grzegorz_image};
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
show_grzegorz_image(mpv.clone()).await?;
|
||||||
|
|
||||||
let addr = SocketAddr::new(resolve(&args.host).await?, args.port);
|
let addr = SocketAddr::new(resolve(&args.host).await?, args.port);
|
||||||
log::info!("Starting API on {}", addr);
|
log::info!("Starting API on {}", addr);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{fs::create_dir_all, io::Write, path::Path};
|
use std::{fs::create_dir_all, io::Write, path::Path};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use mpvipc_async::Mpv;
|
use mpvipc_async::{Mpv, MpvExt};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use tokio::process::{Child, Command};
|
use tokio::process::{Child, Command};
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ use crate::MpvConnectionArgs;
|
||||||
|
|
||||||
const DEFAULT_MPV_CONFIG_CONTENT: &str = include_str!("../assets/default-mpv.conf");
|
const DEFAULT_MPV_CONFIG_CONTENT: &str = include_str!("../assets/default-mpv.conf");
|
||||||
|
|
||||||
|
const THE_MAN_PNG: &[u8] = include_bytes!("../assets/the_man.png");
|
||||||
|
|
||||||
pub fn create_mpv_config_file(args_config_file: Option<String>) -> anyhow::Result<NamedTempFile> {
|
pub fn create_mpv_config_file(args_config_file: Option<String>) -> anyhow::Result<NamedTempFile> {
|
||||||
let file_content = if let Some(path) = args_config_file {
|
let file_content = if let Some(path) = args_config_file {
|
||||||
if !Path::new(&path).exists() {
|
if !Path::new(&path).exists() {
|
||||||
|
@ -115,3 +117,19 @@ pub async fn connect_to_mpv<'a>(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn show_grzegorz_image(mpv: Mpv) -> anyhow::Result<()> {
|
||||||
|
let path = std::env::temp_dir().join("the_man.png");
|
||||||
|
std::fs::write(path.as_path(), THE_MAN_PNG)?;
|
||||||
|
|
||||||
|
mpv.playlist_clear().await?;
|
||||||
|
mpv.playlist_add(
|
||||||
|
path.to_string_lossy().as_ref(),
|
||||||
|
mpvipc_async::PlaylistAddTypeOptions::File,
|
||||||
|
mpvipc_async::PlaylistAddOptions::Append,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
mpv.next().await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue