Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement mediasession set positon state #24885

Merged
Prev

extended android jni with onMediaSessionSetPositionState

  • Loading branch information
shnmorimoto committed Dec 3, 2019
commit 41ff93eca2bf3e8a15d99fedbf7da3a7f9af638a
@@ -255,4 +255,15 @@ public void onMediaSessionPlaybackStateChange(int state) {
return;
}
}

@Override
public void onMediaSessionSetPositionState(float duration, float position, float playbackRate) {
Log.d("onMediaSessionSetPositionState", duration + " " + position + " " + playbackRate);
if (mMediaSession == null) {
mMediaSession = new MediaSession(mServoView, this, getApplicationContext());
}

mMediaSession.setPositionState(duration, position, playbackRate);
This conversation was marked as resolved by ferjm

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Dec 1, 2019

Author Contributor

I have a wrong implementation.(Because setPositionState is not implemented in MediaSession.java.)
Should I call onMediaSessionSetPositionState of Servo.java directly here?
Or is it better to implement setPositionState in MediaSession.java and call it there?

This comment has been minimized.

Copy link
@ferjm

ferjm Dec 2, 2019

Member

Servo.onMediaSessionSetPositionState is what calls this method (note that MainActivity implements the Servo.Client interface).

We need to implement MediaSession.setPositionState. That's where we should modify the existing notification UI to add the current position, the total duration and a progress bar. If you don't feel like hacking on the Android UI, leave the method unimplemented.

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Dec 2, 2019

Author Contributor

Thanks!
I don't have a good understanding of the Android UI.
So this time I will not implement it. Sorry.

return;
}
}
@@ -192,4 +192,8 @@ public void updateMetadata(String title, String artist, String album) {
showMediaSessionControls();
}
}
}

// Not implemented
// see https://github.com/servo/servo/pull/24885#discussion_r352496117
public void setPositionState(float duration, float position, float playbackRate) {}
This conversation was marked as resolved by ferjm

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Dec 2, 2019

Author Contributor

For compile, I added only the signature.

}
@@ -115,6 +115,8 @@
void onMediaSessionMetadata(String title, String artist, String album);

void onMediaSessionPlaybackStateChange(int state);

void onMediaSessionSetPositionState(float duration, float position, float playbackRate);
}
}

@@ -192,6 +192,8 @@ public void mediaSessionAction(int action) {
void onMediaSessionMetadata(String title, String artist, String album);

void onMediaSessionPlaybackStateChange(int state);

void onMediaSessionSetPositionState(float duration, float position, float playbackRate);
}

public interface RunCallback {
@@ -285,5 +287,9 @@ public void onMediaSessionMetadata(String title, String artist, String album) {
public void onMediaSessionPlaybackStateChange(int state) {
mRunCallback.inUIThread(() -> mClient.onMediaSessionPlaybackStateChange(state));
}

public void onMediaSessionSetPositionState(float duration, float position, float playbackRate) {
mRunCallback.inUIThread(() -> mClient.onMediaSessionSetPositionState(duration, position, playbackRate));
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.