use of android.media.session.PlaybackState in project platform_frameworks_base by android.
the class MediaSessions method dump.
private static void dump(int n, PrintWriter writer, MediaController c) {
writer.println(" Controller " + n + ": " + c.getPackageName());
final Bundle extras = c.getExtras();
final long flags = c.getFlags();
final MediaMetadata mm = c.getMetadata();
final PlaybackInfo pi = c.getPlaybackInfo();
final PlaybackState playbackState = c.getPlaybackState();
final List<QueueItem> queue = c.getQueue();
final CharSequence queueTitle = c.getQueueTitle();
final int ratingType = c.getRatingType();
final PendingIntent sessionActivity = c.getSessionActivity();
writer.println(" PlaybackState: " + Util.playbackStateToString(playbackState));
writer.println(" PlaybackInfo: " + Util.playbackInfoToString(pi));
if (mm != null) {
writer.println(" MediaMetadata.desc=" + mm.getDescription());
}
writer.println(" RatingType: " + ratingType);
writer.println(" Flags: " + flags);
if (extras != null) {
writer.println(" Extras:");
for (String key : extras.keySet()) {
writer.println(" " + key + "=" + extras.get(key));
}
}
if (queueTitle != null) {
writer.println(" QueueTitle: " + queueTitle);
}
if (queue != null && !queue.isEmpty()) {
writer.println(" Queue:");
for (QueueItem qi : queue) {
writer.println(" " + qi);
}
}
if (pi != null) {
writer.println(" sessionActivity: " + sessionActivity);
}
}
use of android.media.session.PlaybackState in project platform_frameworks_base by android.
the class MediaSessionRecord method getStateWithUpdatedPosition.
private PlaybackState getStateWithUpdatedPosition() {
PlaybackState state;
long duration = -1;
synchronized (mLock) {
state = mPlaybackState;
if (mMetadata != null && mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
duration = mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
}
}
PlaybackState result = null;
if (state != null) {
if (state.getState() == PlaybackState.STATE_PLAYING || state.getState() == PlaybackState.STATE_FAST_FORWARDING || state.getState() == PlaybackState.STATE_REWINDING) {
long updateTime = state.getLastPositionUpdateTime();
long currentTime = SystemClock.elapsedRealtime();
if (updateTime > 0) {
long position = (long) (state.getPlaybackSpeed() * (currentTime - updateTime)) + state.getPosition();
if (duration >= 0 && position > duration) {
position = duration;
} else if (position < 0) {
position = 0;
}
PlaybackState.Builder builder = new PlaybackState.Builder(state);
builder.setState(state.getState(), position, state.getPlaybackSpeed(), currentTime);
result = builder.build();
}
}
}
return result == null ? state : result;
}
use of android.media.session.PlaybackState in project android_frameworks_base by DirtyUnicorns.
the class MediaSessionRecord method getStateWithUpdatedPosition.
private PlaybackState getStateWithUpdatedPosition() {
PlaybackState state;
long duration = -1;
synchronized (mLock) {
state = mPlaybackState;
if (mMetadata != null && mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
duration = mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
}
}
PlaybackState result = null;
if (state != null) {
if (state.getState() == PlaybackState.STATE_PLAYING || state.getState() == PlaybackState.STATE_FAST_FORWARDING || state.getState() == PlaybackState.STATE_REWINDING) {
long updateTime = state.getLastPositionUpdateTime();
long currentTime = SystemClock.elapsedRealtime();
if (updateTime > 0) {
long position = (long) (state.getPlaybackSpeed() * (currentTime - updateTime)) + state.getPosition();
if (duration >= 0 && position > duration) {
position = duration;
} else if (position < 0) {
position = 0;
}
PlaybackState.Builder builder = new PlaybackState.Builder(state);
builder.setState(state.getState(), position, state.getPlaybackSpeed(), currentTime);
result = builder.build();
}
}
}
return result == null ? state : result;
}
use of android.media.session.PlaybackState in project android_frameworks_base by AOSPA.
the class MediaSessions method dump.
private static void dump(int n, PrintWriter writer, MediaController c) {
writer.println(" Controller " + n + ": " + c.getPackageName());
final Bundle extras = c.getExtras();
final long flags = c.getFlags();
final MediaMetadata mm = c.getMetadata();
final PlaybackInfo pi = c.getPlaybackInfo();
final PlaybackState playbackState = c.getPlaybackState();
final List<QueueItem> queue = c.getQueue();
final CharSequence queueTitle = c.getQueueTitle();
final int ratingType = c.getRatingType();
final PendingIntent sessionActivity = c.getSessionActivity();
writer.println(" PlaybackState: " + Util.playbackStateToString(playbackState));
writer.println(" PlaybackInfo: " + Util.playbackInfoToString(pi));
if (mm != null) {
writer.println(" MediaMetadata.desc=" + mm.getDescription());
}
writer.println(" RatingType: " + ratingType);
writer.println(" Flags: " + flags);
if (extras != null) {
writer.println(" Extras:");
for (String key : extras.keySet()) {
writer.println(" " + key + "=" + extras.get(key));
}
}
if (queueTitle != null) {
writer.println(" QueueTitle: " + queueTitle);
}
if (queue != null && !queue.isEmpty()) {
writer.println(" Queue:");
for (QueueItem qi : queue) {
writer.println(" " + qi);
}
}
if (pi != null) {
writer.println(" sessionActivity: " + sessionActivity);
}
}
use of android.media.session.PlaybackState in project android_frameworks_base by ResurrectionRemix.
the class MediaSessionRecord method getStateWithUpdatedPosition.
private PlaybackState getStateWithUpdatedPosition() {
PlaybackState state;
long duration = -1;
synchronized (mLock) {
state = mPlaybackState;
if (mMetadata != null && mMetadata.containsKey(MediaMetadata.METADATA_KEY_DURATION)) {
duration = mMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
}
}
PlaybackState result = null;
if (state != null) {
if (state.getState() == PlaybackState.STATE_PLAYING || state.getState() == PlaybackState.STATE_FAST_FORWARDING || state.getState() == PlaybackState.STATE_REWINDING) {
long updateTime = state.getLastPositionUpdateTime();
long currentTime = SystemClock.elapsedRealtime();
if (updateTime > 0) {
long position = (long) (state.getPlaybackSpeed() * (currentTime - updateTime)) + state.getPosition();
if (duration >= 0 && position > duration) {
position = duration;
} else if (position < 0) {
position = 0;
}
PlaybackState.Builder builder = new PlaybackState.Builder(state);
builder.setState(state.getState(), position, state.getPlaybackSpeed(), currentTime);
result = builder.build();
}
}
}
return result == null ? state : result;
}
Aggregations