Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Unified Diff: content/public/browser/media_session.h

Issue 2441423002: Add MediaSessionObserver to allow clients observe MediaSession directly (Closed)
Patch Set: fixed Android build Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/browser/media_session.h
diff --git a/content/public/browser/media_session.h b/content/public/browser/media_session.h
new file mode 100644
index 0000000000000000000000000000000000000000..405102792cc9de242560bba6032d753e15b03061
--- /dev/null
+++ b/content/public/browser/media_session.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_
+#define CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_
+
+#include "base/macros.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class WebContents;
+
+// MediaSession manages the media session and audio focus for a given
+// WebContents. There is only one MediaSession per WebContents. The underlying
+// implementation will request audio focus when players want to play audio, and
whywhat 2016/10/24 20:29:39 nit: Don't think sharing the implementation detail
Zhiqiang Zhang (Slow) 2016/10/25 19:51:43 Removed.
+// will respond to audio focus changes (such as another tab or app start to
+// produce audio).
+//
+// MediaSession allows clients to observe its changes via MediaSessionObserver,
+// and allow clients to resume/suspend/stop the managed players. MediaSession is
whywhat 2016/10/24 20:29:39 nit: s/allow/allows
Zhiqiang Zhang (Slow) 2016/10/25 19:51:43 Done.
+// also the interface for communicating with blink::MediaSession.
whywhat 2016/10/24 20:29:39 nit: same w/r/t sharing the implementation details
Zhiqiang Zhang (Slow) 2016/10/25 19:51:43 Done.
+class MediaSession {
+ public:
+ enum class SuspendType {
+ // Suspended by the system because a transient sound needs to be played.
+ SYSTEM,
+ // Suspended by the UI.
+ UI,
+ // Suspended by the page via script or user interaction.
+ CONTENT,
+ };
+
+ // Returns the MediaSession associated to this WebContents. Creates one if
+ // none is currently available.
+ CONTENT_EXPORT static MediaSession* Get(WebContents* contents);
+
+ virtual ~MediaSession() = default;
+
+ // Resume the media session.
+ // |type| represents the origin of the request.
+ virtual void Resume(SuspendType suspend_type) = 0;
+
+ // Resume the media session.
+ // |type| represents the origin of the request.
+ virtual void Suspend(SuspendType suspend_type) = 0;
+
+ // Resume the media session.
+ // |type| represents the origin of the request.
+ virtual void Stop(SuspendType suspend_type) = 0;
+
+ private:
+ // This interface should only be implemented inside content.
+ friend class MediaSessionImpl;
+ MediaSession() = default;
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_MEDIA_SESSION_H_

Powered by Google App Engine
This is Rietveld 408576698