cosmic-player/src/mime.rs
leyoda a670d2afd7
Some checks failed
Validate .desktop files / validate (push) Has been cancelled
player: register MPEG and WMV support cleanly
2026-05-18 17:28:19 +02:00

27 lines
827 B
Rust

const DESKTOP_ENTRY: &str = include_str!("../res/com.system76.CosmicPlayer.desktop");
pub fn supported_mime_types() -> Vec<String> {
DESKTOP_ENTRY
.lines()
.find_map(|line| line.strip_prefix("MimeType="))
.map(|mime_types| {
mime_types
.split(';')
.filter(|mime_type| !mime_type.is_empty())
.map(ToOwned::to_owned)
.collect()
})
.unwrap_or_default()
}
pub fn supported_uri_schemes() -> Vec<String> {
supported_mime_types()
.into_iter()
.filter_map(|mime_type| {
mime_type
.strip_prefix("x-scheme-handler/")
.map(ToOwned::to_owned)
})
.chain(["file".to_string(), "http".to_string(), "https".to_string()])
.collect()
}