Add main.rs entry point
This commit is contained in:
60
src/main.rs
Normal file
60
src/main.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
//! MoMentry Playground 主入口
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use clap::Parser;
|
||||||
|
use log::{error, info};
|
||||||
|
|
||||||
|
mod player;
|
||||||
|
mod ui;
|
||||||
|
mod viewer;
|
||||||
|
mod api;
|
||||||
|
mod input;
|
||||||
|
|
||||||
|
use player::VideoPlayer;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(name = "momentry")]
|
||||||
|
#[command(about = "MoMentry Playground - 統一播放、檢視、監控")]
|
||||||
|
struct Args {
|
||||||
|
#[arg(short, long, default_value = "800")]
|
||||||
|
width: u32,
|
||||||
|
|
||||||
|
#[arg(short, long, default_value = "600")]
|
||||||
|
height: u32,
|
||||||
|
|
||||||
|
#[arg(short, long)]
|
||||||
|
file: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
||||||
|
|
||||||
|
let args = Args::parse();
|
||||||
|
info!("MoMentry Playground starting...");
|
||||||
|
|
||||||
|
if let Err(e) = run(args) {
|
||||||
|
error!("Application error: {}", e);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(args: Args) -> Result<()> {
|
||||||
|
info!("Initializing window: {}x{}", args.width, args.height);
|
||||||
|
info!("Initializing video player...");
|
||||||
|
|
||||||
|
let mut player = VideoPlayer::new()?;
|
||||||
|
|
||||||
|
if let Some(path) = args.file {
|
||||||
|
info!("Loading file: {}", path);
|
||||||
|
player.open(&path)?;
|
||||||
|
player.play()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
info!("Main loop started - waiting for events...");
|
||||||
|
|
||||||
|
loop {
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user