use std::env;
use std::fs::File;
+#[cfg(not(target_os = "windows"))]
+use std::io::{BufRead, BufReader};
use std::io::Write;
use std::path::Path;
use std::time::{Duration, Instant};
acontrol: AudioControl,
vcontrol: VideoControl,
+ thr_w: usize,
+ thr_h: usize,
+
play_video: bool,
play_audio: bool,
has_video: bool,
acontrol, vcontrol,
+ thr_w: 384,
+ thr_h: 288,
+
play_video: true,
play_audio: true,
has_video: false,
}
match self.sc_size {
- ScaleSize::Auto => {
- while (width <= 384) && (height <= 288) {
+ ScaleSize::Auto if self.thr_w > 0 && self.thr_h > 0 => {
+ while (width <= self.thr_w) && (height <= self.thr_h) {
width <<= 1;
height <<= 1;
}
},
+ ScaleSize::Auto => {},
ScaleSize::Times(factor) => {
let nw = ((width as f32) * factor).ceil() as usize;
let nh = ((height as f32) * factor).ceil() as usize;
let mut builder = player.vsystem.window("NihAV Player", 640, 480);
let mut window = builder.position_centered().hidden().build().expect("should be able to centre window");
+ #[cfg(not(target_os = "windows"))]
+ #[allow(deprecated)]
+ if let Some(home_path) = std::env::home_dir() {
+ let mut rcfile = home_path.into_os_string();
+ rcfile.push(std::path::MAIN_SEPARATOR_STR);
+ rcfile.push(".naplayerrc");
+ debug_log!(self; {format!("opening settings file {rcfile}")});
+ if let Ok(file) = File::open(rcfile) {
+ let br = BufReader::new(file);
+ for (n, line) in br.lines().enumerate() {
+ if let Ok(line) = line {
+ let mut words: Vec<&str> = line.split_ascii_whitespace().collect();
+ if words.is_empty() || words[0].starts_with('#') {
+ continue;
+ }
+ if words.len() == 1 && words[0].contains('=') {
+ words = words[0].split('=').collect();
+ }
+ if words.is_empty() {
+ continue;
+ }
+ if words[0] == "scale_thr" {
+ let last_arg = words[words.len() - 1];
+ let dim: Vec<&str> = last_arg.split(['x', 'X']).collect();
+ if dim.len() != 2 {
+ println!(" expected 'scale_thr=WxH', got 'scale_thr={last_arg}'");
+ continue;
+ }
+ if let (Ok(thr_w), Ok(thr_h)) = (dim[0].parse::<usize>(), dim[1].parse::<usize>()) {
+ debug_log!(self; {format!(" set autoscale threshold to {thr_w}x{thr_h}")});
+ player.thr_w = thr_w;
+ player.thr_h = thr_h;
+ } else {
+ println!(" expected 'scale_thr=WxH', got 'scale_thr={last_arg}'");
+ continue;
+ }
+ }
+ } else {
+ println!(" error at line {n}");
+ break;
+ }
+ }
+ }
+ }
+
let mut aiter = args.iter().skip(1);
let mut seek_time = NATimePoint::None;
while let Some(arg) = aiter.next() {