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

Unified Diff: media/base/android/media_player_android.h

Issue 643353002: Listen to the audio focus event for MSE/EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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: media/base/android/media_player_android.h
diff --git a/media/base/android/media_player_android.h b/media/base/android/media_player_android.h
index b339215ec8845cbc9f72c8cb53330bb161f8bdb5..d5e0895051199d3df2c2c8964c0cd8c0daf3cb43 100644
--- a/media/base/android/media_player_android.h
+++ b/media/base/android/media_player_android.h
@@ -9,7 +9,9 @@
#include <string>
#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
+#include "media/base/android/media_player_listener.h"
#include "media/base/media_export.h"
#include "ui/gl/android/scoped_java_surface.h"
#include "url/gurl.h"
@@ -86,11 +88,29 @@ class MEDIA_EXPORT MediaPlayerAndroid {
const RequestMediaResourcesCB& request_media_resources_cb,
const GURL& frame_url);
+ // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to
+ // media interrupt events. And have a separate child class to listen to all
+ // the events needed by MediaPlayerBridge. http://crbug.com/422597.
+ // MediaPlayerListener callbacks.
+ virtual void OnVideoSizeChanged(int width, int height);
+ virtual void OnMediaError(int error_type);
+ virtual void OnBufferingUpdate(int percent);
+ virtual void OnPlaybackComplete();
+ virtual void OnMediaInterrupted();
+ virtual void OnSeekComplete();
+ virtual void OnMediaPrepared();
+
+ // Attach/Detaches |listener_| for listening to all the events.
+ void AttachListener(jobject j_media_player);
xhwang 2014/10/14 18:23:30 It seems |j_media_player| can be NULL here. What d
qinmin 2014/10/14 21:55:51 Done.
+ void DetachListener();
+
MediaPlayerManager* manager() { return manager_; }
RequestMediaResourcesCB request_media_resources_cb_;
private:
+ friend class MediaPlayerListener;
+
// Player ID assigned to this player.
int player_id_;
@@ -100,6 +120,13 @@ class MEDIA_EXPORT MediaPlayerAndroid {
// Url for the frame that contains this player.
GURL frame_url_;
+ // Listener object that listens to all the media player events.
+ scoped_ptr<MediaPlayerListener> listener_;
+
+ // Weak pointer passed to |listener_| for callbacks.
+ // NOTE: Weak pointers must be invalidated before all other member variables.
+ base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid);
};

Powered by Google App Engine
This is Rietveld 408576698