From 3698c703fc0f231d06dc9207aff961a8b0129d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Thu, 19 Sep 2024 00:00:06 +0100 Subject: [PATCH] [wasm] feat: expose media name --- um_wasm/src/exports/qmc.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/um_wasm/src/exports/qmc.rs b/um_wasm/src/exports/qmc.rs index 5268490..80c0def 100644 --- a/um_wasm/src/exports/qmc.rs +++ b/um_wasm/src/exports/qmc.rs @@ -1,5 +1,5 @@ use crate::errors::map_js_error; -use umc_qmc::footer::FooterParseError; +use umc_qmc::footer::{Data as FooterData, FooterParseError}; use umc_qmc::QMCv2Cipher; use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::JsError; @@ -57,4 +57,13 @@ impl JsQMCFooter { pub fn size(&self) -> usize { self.0.size } + + /// Get media name (MusicEx) + #[wasm_bindgen(getter, js_name=mediaName)] + pub fn get_media_name(&self) -> Option { + match &self.0.data { + FooterData::PCv2MusicEx(metadata) => Some(metadata.media_filename.clone()), + _ => None, + } + } }