mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
MediaSession Android bits
This commit is contained in:
parent
7ca74d598c
commit
3f6569447d
4 changed files with 34 additions and 3 deletions
|
@ -15,9 +15,7 @@ use jni::{errors, JNIEnv, JavaVM};
|
||||||
use libc::{dup2, pipe, read};
|
use libc::{dup2, pipe, read};
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use simpleservo::{self, gl_glue, ServoGlue, SERVO};
|
use simpleservo::{self, gl_glue, ServoGlue, SERVO};
|
||||||
use simpleservo::{
|
use simpleservo::{Coordinates, EventLoopWaker, HostTrait, InitOptions, VRInitOptions};
|
||||||
Coordinates, EventLoopWaker, HostTrait, InitOptions, MediaSessionEvent, VRInitOptions,
|
|
||||||
};
|
|
||||||
use std::os::raw::{c_char, c_int, c_void};
|
use std::os::raw::{c_char, c_int, c_void};
|
||||||
use std::ptr::{null, null_mut};
|
use std::ptr::{null, null_mut};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
//import org.mozilla.servo.MediaSessionCallback;
|
||||||
|
|
||||||
import org.mozilla.servoview.ServoView;
|
import org.mozilla.servoview.ServoView;
|
||||||
import org.mozilla.servoview.Servo;
|
import org.mozilla.servoview.Servo;
|
||||||
|
|
||||||
|
@ -41,6 +43,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
||||||
ProgressBar mProgressBar;
|
ProgressBar mProgressBar;
|
||||||
TextView mIdleText;
|
TextView mIdleText;
|
||||||
boolean mCanGoBack;
|
boolean mCanGoBack;
|
||||||
|
// MediaSession mSession;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -217,4 +220,18 @@ public class MainActivity extends Activity implements Servo.Client {
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMediaSessionMetadata(String title, String artist, String album) {
|
||||||
|
Log.d("SERVOMEDIA", "METADATA");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMediaSessionPlaybackStateChange(int state) {
|
||||||
|
Log.d("SERVOMEDIA", "PLAYBACK STATE CHANGED");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private void createMediaSession() {
|
||||||
|
mSession = new MediaSession(this, "ServoMediaSession");
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,10 @@ public class JNIServo {
|
||||||
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
||||||
|
|
||||||
void onShutdownComplete();
|
void onShutdownComplete();
|
||||||
|
|
||||||
|
void onMediaSessionMetadata(String title, String artist, String album);
|
||||||
|
|
||||||
|
void onMediaSessionPlaybackStateChange(int state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,10 @@ public class Servo {
|
||||||
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
||||||
|
|
||||||
void onRedrawing(boolean redrawing);
|
void onRedrawing(boolean redrawing);
|
||||||
|
|
||||||
|
void onMediaSessionMetadata(String title, String artist, String album);
|
||||||
|
|
||||||
|
void onMediaSessionPlaybackStateChange(int state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RunCallback {
|
public interface RunCallback {
|
||||||
|
@ -269,5 +273,13 @@ public class Servo {
|
||||||
public void onRedrawing(boolean redrawing) {
|
public void onRedrawing(boolean redrawing) {
|
||||||
mRunCallback.inUIThread(() -> mClient.onRedrawing(redrawing));
|
mRunCallback.inUIThread(() -> mClient.onRedrawing(redrawing));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onMediaSessionMetadata(String title, String artist, String album) {
|
||||||
|
mRunCallback.inUIThread(() -> mClient.onMediaSessionMetadata(title, artist, album));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMediaSessionPlaybackStateChange(int state) {
|
||||||
|
mRunCallback.inUIThread(() -> mClient.onMediaSessionPlaybackStateChange(state));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue