(_env: JNIEnv, _class: JClass)
| 31 | |
| 32 | #[no_mangle] |
| 33 | pub extern "system" fn getPlaybackPosition(_env: JNIEnv, _class: JClass) -> jlong { |
| 34 | let result = std::panic::catch_unwind(|| { |
| 35 | block_on(async { |
| 36 | match get_spotify_session() { |
| 37 | Ok(Some(session)) => { |
| 38 | let timeline = session.GetTimelineProperties()?; |
| 39 | let position = timeline.Position()?; |
| 40 | Ok((position.Duration / 10_000) as jlong) |
| 41 | } |
| 42 | _ => Err(Error::new(E_FAIL, "Spotify session not available")), |
| 43 | } |
| 44 | }) |
| 45 | }); |
| 46 | |
| 47 | match result { |
| 48 | Ok(Ok(position)) => position, |
| 49 | _ => -1, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | #[no_mangle] |
| 54 | pub extern "system" fn getTrackDuration(_env: JNIEnv, _class: JClass) -> jlong { |
nothing calls this directly
no test coverage detected