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

Side by Side Diff: content/browser/android/content_video_view.h

Issue 103583005: Restart fullscreen video playback when switching back from background (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: handle everything at browser side Created 7 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/jni_helper.h" 10 #include "base/android/jni_helper.h"
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class BrowserMediaPlayerManager; 19 class BrowserMediaPlayerManager;
20 class ContentViewCoreImpl;
20 21
21 // Native mirror of ContentVideoView.java. This class is responsible for 22 // Native mirror of ContentVideoView.java. This class is responsible for
22 // creating the Java video view and pass all the player status change to 23 // creating the Java video view and pass all the player status change to
23 // it. It accepts media control from Java class, and forwards it to 24 // it. It accepts media control from Java class, and forwards it to
24 // MediaPlayerManagerImpl. 25 // MediaPlayerManagerImpl.
25 class ContentVideoView { 26 class ContentVideoView {
26 public: 27 public:
27 // Construct a ContentVideoView object. The |manager| will handle all the 28 // Construct a ContentVideoView object. The |manager| will handle all the
28 // playback controls from the Java class. 29 // playback controls from the Java class.
29 ContentVideoView( 30 ContentVideoView(
30 const base::android::ScopedJavaLocalRef<jobject>& context, 31 const base::android::ScopedJavaLocalRef<jobject>& context,
31 const base::android::ScopedJavaLocalRef<jobject>& client, 32 const base::android::ScopedJavaLocalRef<jobject>& client,
32 BrowserMediaPlayerManager* manager); 33 BrowserMediaPlayerManager* manager);
33 34
35 ContentVideoView(BrowserMediaPlayerManager* manager);
36
34 ~ContentVideoView(); 37 ~ContentVideoView();
35 38
36 // To open another video on existing ContentVideoView. 39 // To open another video on existing ContentVideoView.
37 void OpenVideo(); 40 void OpenVideo();
38 41
39 static bool RegisterContentVideoView(JNIEnv* env); 42 static bool RegisterContentVideoView(JNIEnv* env);
40 static void KeepScreenOn(bool screen_on); 43 static void KeepScreenOn(bool screen_on);
41 44
42 // Return true if there is existing ContentVideoView object. 45 // Return the singleton object or NULL.
43 static bool HasContentVideoView(); 46 static ContentVideoView* GetInstance();
44 47
45 // Getter method called by the Java class to get the media information. 48 // Getter method called by the Java class to get the media information.
46 int GetVideoWidth(JNIEnv*, jobject obj) const; 49 int GetVideoWidth(JNIEnv*, jobject obj) const;
47 int GetVideoHeight(JNIEnv*, jobject obj) const; 50 int GetVideoHeight(JNIEnv*, jobject obj) const;
48 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; 51 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const;
49 int GetCurrentPosition(JNIEnv*, jobject obj) const; 52 int GetCurrentPosition(JNIEnv*, jobject obj) const;
50 bool IsPlaying(JNIEnv*, jobject obj); 53 bool IsPlaying(JNIEnv*, jobject obj);
51 void UpdateMediaMetadata(JNIEnv*, jobject obj); 54 void UpdateMediaMetadata(JNIEnv*, jobject obj);
52 55
53 // Called when the Java fullscreen view is destroyed. If 56 // Called when the Java fullscreen view is destroyed. If
54 // |release_media_player| is true, |manager_| needs to release the player 57 // |release_media_player| is true, |manager_| needs to release the player
55 // as we are quitting the app. 58 // as we are quitting the app.
56 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); 59 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player);
57 60
61 // Supposed to be called when the application paused or stopped.
62 // Destroys the fullscreen view in a way that it can be recreated
63 // via ResumeFullscreenIfSuspended.
64 void SuspendFullscreen();
65
66 // Supposed to be called when the application switches back to foreground.
67 // Recreates the fullscreen view if it was suspended via SuspendFullscreen.
68 void ResumeFullscreenIfSuspended();
69
58 // Media control method called by the Java class. 70 // Media control method called by the Java class.
59 void SeekTo(JNIEnv*, jobject obj, jint msec); 71 void SeekTo(JNIEnv*, jobject obj, jint msec);
60 void Play(JNIEnv*, jobject obj); 72 void Play(JNIEnv*, jobject obj);
61 void Pause(JNIEnv*, jobject obj); 73 void Pause(JNIEnv*, jobject obj);
62 74
63 // Called by the Java class to pass the surface object to the player. 75 // Called by the Java class to pass the surface object to the player.
64 void SetSurface(JNIEnv*, jobject obj, jobject surface); 76 void SetSurface(JNIEnv*, jobject obj, jobject surface);
65 77
66 // Method called by |manager_| to inform the Java class about player status 78 // Method called by |manager_| to inform the Java class about player status
67 // change. 79 // change.
68 void UpdateMediaMetadata(); 80 void UpdateMediaMetadata();
69 void OnMediaPlayerError(int errorType); 81 void OnMediaPlayerError(int errorType);
70 void OnVideoSizeChanged(int width, int height); 82 void OnVideoSizeChanged(int width, int height);
71 void OnBufferingUpdate(int percent); 83 void OnBufferingUpdate(int percent);
72 void OnPlaybackComplete(); 84 void OnPlaybackComplete();
73 void OnExitFullscreen(); 85 void OnExitFullscreen();
74 86
75 // Return the corresponing ContentVideoView Java object if any. 87 // Return the corresponing ContentVideoView Java object if any.
76 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); 88 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env);
77 89
90 // Creates the corresponding ContentVideoView Java object.
91 JavaObjectWeakGlobalRef CreateJavaObject(
92 ContentViewCoreImpl* content_view_core);
qinmin 2013/12/18 02:09:46 no need for the input param, you can get that from
93
78 private: 94 private:
79 // Destroy the |j_content_video_view_|. If |native_view_destroyed| is true, 95 // Destroy the |j_content_video_view_|. If |native_view_destroyed| is true,
80 // no further calls to the native object is allowed. 96 // no further calls to the native object is allowed.
81 void DestroyContentVideoView(bool native_view_destroyed); 97 void DestroyContentVideoView(bool native_view_destroyed);
82 98
83 // Object that manages the fullscreen media player. It is responsible for 99 // Object that manages the fullscreen media player. It is responsible for
84 // handling all the playback controls. 100 // handling all the playback controls.
85 BrowserMediaPlayerManager* manager_; 101 BrowserMediaPlayerManager* manager_;
86 102
87 // Weak reference of corresponding Java object. 103 // Weak reference of corresponding Java object.
88 JavaObjectWeakGlobalRef j_content_video_view_; 104 JavaObjectWeakGlobalRef j_content_video_view_;
89 105
106 enum FullscreenState {
107 Entered,
108 Suspend,
109 Resume
110 } fullscreen_state_;
111
90 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); 112 DISALLOW_COPY_AND_ASSIGN(ContentVideoView);
91 }; 113 };
92 114
93 } // namespace content 115 } // namespace content
94 116
95 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ 117 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/android/content_video_view.cc » ('j') | content/browser/android/content_video_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698