player: register MPEG and WMV support cleanly
Some checks failed
Validate .desktop files / validate (push) Has been cancelled
Some checks failed
Validate .desktop files / validate (push) Has been cancelled
This commit is contained in:
parent
fd03f98738
commit
a670d2afd7
4 changed files with 52 additions and 2 deletions
|
|
@ -33,6 +33,7 @@ mod config;
|
|||
mod key_bind;
|
||||
mod localize;
|
||||
mod menu;
|
||||
mod mime;
|
||||
#[cfg(feature = "mpris-server")]
|
||||
mod mpris;
|
||||
mod project;
|
||||
|
|
|
|||
27
src/mime.rs
Normal file
27
src/mime.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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()
|
||||
}
|
||||
|
|
@ -138,12 +138,12 @@ impl RootInterface for Player {
|
|||
|
||||
async fn supported_uri_schemes(&self) -> fdo::Result<Vec<String>> {
|
||||
log::info!("SupportedUriSchemes");
|
||||
Ok(vec![])
|
||||
Ok(crate::mime::supported_uri_schemes())
|
||||
}
|
||||
|
||||
async fn supported_mime_types(&self) -> fdo::Result<Vec<String>> {
|
||||
log::info!("SupportedMimeTypes");
|
||||
Ok(vec![])
|
||||
Ok(crate::mime::supported_mime_types())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue