MCPcopy Create free account
hub / github.com/LabyStudio/java-spotify-api / getTrackTitle

Function getTrackTitle

rust/src/lib.rs:75–94  ·  view source on GitHub ↗
(_env: JNIEnv, _class: JClass)

Source from the content-addressed store, hash-verified

73
74#[no_mangle]
75pub extern "system" fn getTrackTitle(_env: JNIEnv, _class: JClass) -> *const c_char {
76 let result = std::panic::catch_unwind(|| {
77 block_on(async {
78 match get_spotify_session()? {
79 Some(session) => {
80 let props = session.TryGetMediaPropertiesAsync()?.get()?;
81 let title = props.Title()?.to_string();
82 // Safely create CString, fallback to empty string if null bytes present
83 Ok(CString::new(title).unwrap_or_default().into_raw())
84 }
85 _ => Err(Error::new(E_FAIL, "Spotify session not found")),
86 }
87 })
88 });
89
90 match result {
91 Ok(Ok(ptr)) => ptr,
92 _ => std::ptr::null(),
93 }
94}
95
96#[no_mangle]
97pub extern "system" fn getArtistName(_env: JNIEnv, _class: JClass) -> *const c_char {

Callers

nothing calls this directly

Calls 2

get_spotify_sessionFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected