2023-09-21 22:49:36 +02:00
|
|
|
package android.media.session;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
|
import android.content.Context;
|
2024-11-27 14:59:37 +01:00
|
|
|
import android.media.AudioAttributes;
|
2023-09-21 22:49:36 +02:00
|
|
|
import android.media.MediaDescription;
|
|
|
|
|
import android.media.MediaMetadata;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
|
|
|
|
|
public class MediaSession {
|
|
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
private List<QueueItem> queue;
|
|
|
|
|
|
2023-09-21 22:49:36 +02:00
|
|
|
public static final class Token {}
|
|
|
|
|
|
|
|
|
|
public static abstract class Callback {}
|
|
|
|
|
|
|
|
|
|
public static class QueueItem {
|
2024-07-15 16:39:45 +02:00
|
|
|
long id;
|
|
|
|
|
MediaDescription description;
|
|
|
|
|
|
|
|
|
|
public QueueItem(MediaDescription description, long id) {
|
|
|
|
|
this.description = description;
|
|
|
|
|
this.id = id;
|
|
|
|
|
}
|
2023-09-21 22:49:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MediaSession(Context context, String tag) {}
|
|
|
|
|
|
|
|
|
|
public Token getSessionToken() {
|
|
|
|
|
return new Token();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFlags(int flags) {}
|
|
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
public void setCallback(Callback callback, Handler handler) {
|
|
|
|
|
nativeSetCallback(callback);
|
|
|
|
|
}
|
2023-09-21 22:49:36 +02:00
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
public void setCallback(Callback callback) {
|
|
|
|
|
nativeSetCallback(callback);
|
|
|
|
|
}
|
2024-02-17 15:15:05 +01:00
|
|
|
|
2023-09-21 22:49:36 +02:00
|
|
|
public void setMediaButtonReceiver(PendingIntent pendingIntent) {}
|
|
|
|
|
|
|
|
|
|
public void setActive(boolean active) {}
|
|
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
public void setPlaybackState(PlaybackState state) {
|
|
|
|
|
String title = null;
|
|
|
|
|
String subTitle = null;
|
|
|
|
|
String artUrl = null;
|
|
|
|
|
if (queue != null) for (QueueItem item : queue) {
|
|
|
|
|
if (item.id == state.activeQueueItemId) {
|
|
|
|
|
title = item.description.title.toString();
|
|
|
|
|
subTitle = item.description.subtitle.toString();
|
2024-11-27 14:59:37 +01:00
|
|
|
artUrl = item.description.iconUri == null ? null : item.description.iconUri.toString();
|
2024-07-15 16:39:45 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nativeSetState(state.state, state.actions, state.position, state.updateTime, title, subTitle, artUrl);
|
|
|
|
|
}
|
2023-09-21 22:49:36 +02:00
|
|
|
|
|
|
|
|
public void setMetadata(MediaMetadata metadata) {}
|
|
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
public void setQueue(List<QueueItem> queue) {
|
|
|
|
|
this.queue = queue;
|
|
|
|
|
}
|
2024-02-17 15:17:37 +01:00
|
|
|
|
|
|
|
|
public void release() {}
|
2024-07-15 16:39:45 +02:00
|
|
|
|
2024-11-27 14:59:37 +01:00
|
|
|
public void setPlaybackToLocal(AudioAttributes audioAttributes) {}
|
|
|
|
|
|
2024-07-15 16:39:45 +02:00
|
|
|
protected native void nativeSetState(int state, long actions, long position, long updateTime, String title, String subTitle, String artUrl);
|
|
|
|
|
protected native void nativeSetCallback(Callback callback);
|
2023-09-21 22:49:36 +02:00
|
|
|
}
|