mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
libservo: Move Android MediaSessionAction
conversion to servoshell (#35225)
The conversion of an integer into a `MediaSessionAction` is Android-specific and thus shouldn't be used throughout the source code. This change moves the conversion to the Android port of servoshell. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
764feada30
commit
1aae7a441f
2 changed files with 15 additions and 18 deletions
|
@ -736,20 +736,3 @@ pub enum MediaSessionActionType {
|
||||||
/// The action intent is to move the playback time to a specific time.
|
/// The action intent is to move the playback time to a specific time.
|
||||||
SeekTo,
|
SeekTo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<i32> for MediaSessionActionType {
|
|
||||||
fn from(value: i32) -> MediaSessionActionType {
|
|
||||||
match value {
|
|
||||||
1 => MediaSessionActionType::Play,
|
|
||||||
2 => MediaSessionActionType::Pause,
|
|
||||||
3 => MediaSessionActionType::SeekBackward,
|
|
||||||
4 => MediaSessionActionType::SeekForward,
|
|
||||||
5 => MediaSessionActionType::PreviousTrack,
|
|
||||||
6 => MediaSessionActionType::NextTrack,
|
|
||||||
7 => MediaSessionActionType::SkipAd,
|
|
||||||
8 => MediaSessionActionType::Stop,
|
|
||||||
9 => MediaSessionActionType::SeekTo,
|
|
||||||
_ => panic!("Unknown MediaSessionActionType"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ use jni::objects::{GlobalRef, JClass, JObject, JString, JValue, JValueOwned};
|
||||||
use jni::sys::{jboolean, jfloat, jint, jobject};
|
use jni::sys::{jboolean, jfloat, jint, jobject};
|
||||||
use jni::{JNIEnv, JavaVM};
|
use jni::{JNIEnv, JavaVM};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
|
use servo::MediaSessionActionType;
|
||||||
use simpleservo::{
|
use simpleservo::{
|
||||||
DeviceIntRect, EventLoopWaker, InitOptions, InputMethodType, MediaSessionPlaybackState,
|
DeviceIntRect, EventLoopWaker, InitOptions, InputMethodType, MediaSessionPlaybackState,
|
||||||
PromptResult, SERVO,
|
PromptResult, SERVO,
|
||||||
|
@ -414,7 +415,20 @@ pub extern "C" fn Java_org_servo_servoview_JNIServo_mediaSessionAction<'local>(
|
||||||
action: jint,
|
action: jint,
|
||||||
) {
|
) {
|
||||||
debug!("mediaSessionAction");
|
debug!("mediaSessionAction");
|
||||||
call(&mut env, |s| s.media_session_action((action).into()));
|
|
||||||
|
let action = match action {
|
||||||
|
1 => MediaSessionActionType::Play,
|
||||||
|
2 => MediaSessionActionType::Pause,
|
||||||
|
3 => MediaSessionActionType::SeekBackward,
|
||||||
|
4 => MediaSessionActionType::SeekForward,
|
||||||
|
5 => MediaSessionActionType::PreviousTrack,
|
||||||
|
6 => MediaSessionActionType::NextTrack,
|
||||||
|
7 => MediaSessionActionType::SkipAd,
|
||||||
|
8 => MediaSessionActionType::Stop,
|
||||||
|
9 => MediaSessionActionType::SeekTo,
|
||||||
|
_ => return warn!("Ignoring unknown MediaSessionAction"),
|
||||||
|
};
|
||||||
|
call(&mut env, |s| s.media_session_action(action.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WakeupCallback {
|
pub struct WakeupCallback {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue