OLD | NEW |
---|---|
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" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 // MediaPlayerManagerImpl. | 24 // MediaPlayerManagerImpl. |
25 class ContentVideoView { | 25 class ContentVideoView { |
26 public: | 26 public: |
27 // Construct a ContentVideoView object. The |manager| will handle all the | 27 // Construct a ContentVideoView object. The |manager| will handle all the |
28 // playback controls from the Java class. | 28 // playback controls from the Java class. |
29 ContentVideoView( | 29 ContentVideoView( |
30 const base::android::ScopedJavaLocalRef<jobject>& context, | 30 const base::android::ScopedJavaLocalRef<jobject>& context, |
31 const base::android::ScopedJavaLocalRef<jobject>& client, | 31 const base::android::ScopedJavaLocalRef<jobject>& client, |
32 BrowserMediaPlayerManager* manager); | 32 BrowserMediaPlayerManager* manager); |
33 | 33 |
34 ContentVideoView(BrowserMediaPlayerManager* manager); | |
bulach
2014/01/06 15:44:03
nit: explicit
| |
35 | |
34 ~ContentVideoView(); | 36 ~ContentVideoView(); |
35 | 37 |
36 // To open another video on existing ContentVideoView. | 38 // To open another video on existing ContentVideoView. |
37 void OpenVideo(); | 39 void OpenVideo(); |
38 | 40 |
39 static bool RegisterContentVideoView(JNIEnv* env); | 41 static bool RegisterContentVideoView(JNIEnv* env); |
40 static void KeepScreenOn(bool screen_on); | 42 static void KeepScreenOn(bool screen_on); |
41 | 43 |
42 // Return true if there is existing ContentVideoView object. | 44 // Return the singleton object or NULL. |
43 static bool HasContentVideoView(); | 45 static ContentVideoView* GetInstance(); |
44 | 46 |
45 // Getter method called by the Java class to get the media information. | 47 // Getter method called by the Java class to get the media information. |
46 int GetVideoWidth(JNIEnv*, jobject obj) const; | 48 int GetVideoWidth(JNIEnv*, jobject obj) const; |
47 int GetVideoHeight(JNIEnv*, jobject obj) const; | 49 int GetVideoHeight(JNIEnv*, jobject obj) const; |
48 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; | 50 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; |
49 int GetCurrentPosition(JNIEnv*, jobject obj) const; | 51 int GetCurrentPosition(JNIEnv*, jobject obj) const; |
50 bool IsPlaying(JNIEnv*, jobject obj); | 52 bool IsPlaying(JNIEnv*, jobject obj); |
51 void UpdateMediaMetadata(JNIEnv*, jobject obj); | 53 void UpdateMediaMetadata(JNIEnv*, jobject obj); |
52 | 54 |
53 // Called when the Java fullscreen view is destroyed. If | 55 // Called when the Java fullscreen view is destroyed. If |
54 // |release_media_player| is true, |manager_| needs to release the player | 56 // |release_media_player| is true, |manager_| needs to release the player |
55 // as we are quitting the app. | 57 // as we are quitting the app. |
56 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); | 58 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); |
57 | 59 |
60 // Supposed to be called when the application paused or stopped. | |
61 // Destroys the fullscreen view in a way that it can be recreated | |
62 // via ResumeFullscreenIfSuspended. | |
63 void SuspendFullscreen(); | |
64 | |
65 // Supposed to be called when the application switches back to foreground. | |
66 // Recreates the fullscreen view if it was suspended via SuspendFullscreen. | |
67 void ResumeFullscreenIfSuspended(); | |
68 | |
58 // Media control method called by the Java class. | 69 // Media control method called by the Java class. |
59 void SeekTo(JNIEnv*, jobject obj, jint msec); | 70 void SeekTo(JNIEnv*, jobject obj, jint msec); |
60 void Play(JNIEnv*, jobject obj); | 71 void Play(JNIEnv*, jobject obj); |
61 void Pause(JNIEnv*, jobject obj); | 72 void Pause(JNIEnv*, jobject obj); |
62 | 73 |
63 // Called by the Java class to pass the surface object to the player. | 74 // Called by the Java class to pass the surface object to the player. |
64 void SetSurface(JNIEnv*, jobject obj, jobject surface); | 75 void SetSurface(JNIEnv*, jobject obj, jobject surface); |
65 | 76 |
66 // Method called by |manager_| to inform the Java class about player status | 77 // Method called by |manager_| to inform the Java class about player status |
67 // change. | 78 // change. |
68 void UpdateMediaMetadata(); | 79 void UpdateMediaMetadata(); |
69 void OnMediaPlayerError(int errorType); | 80 void OnMediaPlayerError(int errorType); |
70 void OnVideoSizeChanged(int width, int height); | 81 void OnVideoSizeChanged(int width, int height); |
71 void OnBufferingUpdate(int percent); | 82 void OnBufferingUpdate(int percent); |
72 void OnPlaybackComplete(); | 83 void OnPlaybackComplete(); |
73 void OnExitFullscreen(); | 84 void OnExitFullscreen(); |
74 | 85 |
75 // Return the corresponing ContentVideoView Java object if any. | 86 // Return the corresponing ContentVideoView Java object if any. |
76 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); | 87 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); |
77 | 88 |
78 private: | 89 private: |
79 // Destroy the |j_content_video_view_|. If |native_view_destroyed| is true, | 90 // Destroy the |j_content_video_view_|. If |native_view_destroyed| is true, |
80 // no further calls to the native object is allowed. | 91 // no further calls to the native object is allowed. |
81 void DestroyContentVideoView(bool native_view_destroyed); | 92 void DestroyContentVideoView(bool native_view_destroyed); |
82 | 93 |
94 // Creates the corresponding ContentVideoView Java object. | |
95 JavaObjectWeakGlobalRef CreateJavaObject(); | |
96 | |
83 // Object that manages the fullscreen media player. It is responsible for | 97 // Object that manages the fullscreen media player. It is responsible for |
84 // handling all the playback controls. | 98 // handling all the playback controls. |
85 BrowserMediaPlayerManager* manager_; | 99 BrowserMediaPlayerManager* manager_; |
86 | 100 |
87 // Weak reference of corresponding Java object. | 101 // Weak reference of corresponding Java object. |
88 JavaObjectWeakGlobalRef j_content_video_view_; | 102 JavaObjectWeakGlobalRef j_content_video_view_; |
89 | 103 |
104 enum FullscreenState { | |
105 ENTERED, | |
106 SUSPENDED, | |
107 RESUME | |
108 } fullscreen_state_; | |
109 | |
90 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); | 110 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); |
91 }; | 111 }; |
92 | 112 |
93 } // namespace content | 113 } // namespace content |
94 | 114 |
95 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 115 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
OLD | NEW |