Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content_public/browser/MediaSessionObserver.java |
| diff --git a/content/public/android/java/src/org/chromium/content_public/browser/MediaSessionObserver.java b/content/public/android/java/src/org/chromium/content_public/browser/MediaSessionObserver.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..72121257beaa2312409b8704cbeb917f8a143266 |
| --- /dev/null |
| +++ b/content/public/android/java/src/org/chromium/content_public/browser/MediaSessionObserver.java |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.content_public.browser; |
| + |
| +import org.chromium.content_public.common.MediaMetadata; |
| + |
| +/** |
| + * This class is Java implementation of native MediaSessionObserver. The class receives media |
| + * session messages from Java {@link MediaSession}, which acts acts as a proxy forwarding messages |
| + * comming from the native MediaSession. |
| + */ |
| +public abstract class MediaSessionObserver { |
| + /** |
| + * Construct a {@link MediaSessionObserver} and start observing |mediaSession|. |
| + * @param mediaSession The {@link MediaSession} to observe. |
| + */ |
| + public MediaSessionObserver(MediaSession mediaSession) { |
|
boliu
2016/10/29 01:11:28
protected?
Zhiqiang Zhang (Slow)
2016/10/31 11:57:34
Dones.
|
| + mediaSession.addObserver(this); |
|
boliu
2016/10/29 01:11:28
if you have this, then client should never have to
Zhiqiang Zhang (Slow)
2016/10/31 11:57:34
I know we have two solutions for the observers:
A.
boliu
2016/10/31 18:58:55
I didn't say anything about removing observers. Ja
Zhiqiang Zhang (Slow)
2016/10/31 19:50:03
Are you OK if I do A in native and B in Java? It's
boliu
2016/10/31 20:13:19
Do what jam@ says for native. I didn't even look a
Zhiqiang Zhang (Slow)
2016/10/31 22:22:26
OK, so finally I realized what you mean. I was con
|
| + } |
| + |
| + /** |
| + * Called when the observed media session is destroyed. |
| + * |
| + * Gives subclass a chance to do clean up. After the whole loop over |
| + * {@link MediaSessionObserver}s has been finished, {@link MediaSessionObserver#getMediaSession} |
| + * will return null. |
| + */ |
| + public void mediaSessionDestroyed() {} |
| + |
| + /** |
| + * Called when the observed {@link MediaSession} state has changed. |
| + * @param isControllable If the session can be resumed or suspended. |
| + * @param isSuspended if the session currently suspended or not. |
| + */ |
| + public void mediaSessionStateChanged(boolean isControllable, boolean isSuspended) {} |
| + |
| + /** |
| + * Called when the {@link MediaSession} metadata has changed. |
| + * @param metadata the new MediaMetadata after change. |
| + */ |
| + public void mediaSessionMetadataChanged(MediaMetadata metadata) {} |
| +} |