[wasm] feat: expose media name

This commit is contained in:
鲁树人 2024-09-19 00:00:06 +01:00
parent b1605f65ba
commit 3698c703fc

View File

@ -1,5 +1,5 @@
use crate::errors::map_js_error; use crate::errors::map_js_error;
use umc_qmc::footer::FooterParseError; use umc_qmc::footer::{Data as FooterData, FooterParseError};
use umc_qmc::QMCv2Cipher; use umc_qmc::QMCv2Cipher;
use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::prelude::wasm_bindgen;
use wasm_bindgen::JsError; use wasm_bindgen::JsError;
@ -57,4 +57,13 @@ impl JsQMCFooter {
pub fn size(&self) -> usize { pub fn size(&self) -> usize {
self.0.size self.0.size
} }
/// Get media name (MusicEx)
#[wasm_bindgen(getter, js_name=mediaName)]
pub fn get_media_name(&self) -> Option<String> {
match &self.0.data {
FooterData::PCv2MusicEx(metadata) => Some(metadata.media_filename.clone()),
_ => None,
}
}
} }