| 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/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class MediaPlayerManagerAndroid; | 18 class MediaPlayerManagerAndroid; |
| 19 | 19 |
| 20 // Native mirror of ContentVideoView.java. This class is responsible for | 20 // Native mirror of ContentVideoView.java. This class is responsible for |
| 21 // creating the Java video view and pass all the player status change to | 21 // creating the Java video view and pass all the player status change to |
| 22 // it. It accepts media control from Java class, and forwards it to | 22 // it. It accepts media control from Java class, and forwards it to |
| 23 // MediaPlayerManagerAndroid. | 23 // MediaPlayerManagerAndroid. |
| 24 class ContentVideoView { | 24 class ContentVideoView { |
| 25 public: | 25 public: |
| 26 enum { |
| 27 // These are used in java so don't change them unless we can share an enum |
| 28 // from java and remove this enum. |
| 29 PERSONALITY_FULL_SCREEN = 0, |
| 30 PERSONALITY_EMBEDDED = 1, |
| 31 }; |
| 32 |
| 26 // Construct a ContentVideoView object. The |manager| will handle all the | 33 // Construct a ContentVideoView object. The |manager| will handle all the |
| 27 // playback controls from the Java class. | 34 // playback controls from the Java class. |
| 28 explicit ContentVideoView(MediaPlayerManagerAndroid* manager); | 35 explicit ContentVideoView(MediaPlayerManagerAndroid* manager); |
| 29 ~ContentVideoView(); | 36 ~ContentVideoView(); |
| 30 | 37 |
| 31 static bool RegisterContentVideoView(JNIEnv* env); | 38 static bool RegisterContentVideoView(JNIEnv* env); |
| 32 | 39 |
| 33 // Getter method called by the Java class to get the media information. | 40 // Getter method called by the Java class to get the media information. |
| 34 int GetVideoWidth(JNIEnv*, jobject obj) const; | 41 int GetVideoWidth(JNIEnv*, jobject obj) const; |
| 35 int GetVideoHeight(JNIEnv*, jobject obj) const; | 42 int GetVideoHeight(JNIEnv*, jobject obj) const; |
| 36 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; | 43 int GetDurationInMilliSeconds(JNIEnv*, jobject obj) const; |
| 37 int GetCurrentPosition(JNIEnv*, jobject obj) const; | 44 int GetCurrentPosition(JNIEnv*, jobject obj) const; |
| 38 bool IsPlaying(JNIEnv*, jobject obj); | 45 bool IsPlaying(JNIEnv*, jobject obj); |
| 39 void UpdateMediaMetadata(JNIEnv*, jobject obj); | 46 void UpdateMediaMetadata(JNIEnv*, jobject obj); |
| 40 | 47 |
| 41 // Method to create and destroy the Java view. | 48 // Method to create and destroy the Java view. |
| 42 void DestroyContentVideoView(); | 49 void DestroyContentVideoView(); |
| 43 void CreateContentVideoView(); | 50 void CreateContentVideoView(int personality); |
| 44 | 51 |
| 45 // Called when the Java fullscreen view is destroyed. If | 52 // Called when the Java fullscreen view is destroyed. If |
| 46 // |release_media_player| is true, |manager_| needs to release the player | 53 // |release_media_player| is true, |manager_| needs to release the player |
| 47 // as we are quitting the app. | 54 // as we are quitting the app. |
| 48 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); | 55 void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); |
| 49 | 56 |
| 50 // Media control method called by the Java class. | 57 // Media control method called by the Java class. |
| 51 void SeekTo(JNIEnv*, jobject obj, jint msec); | 58 void SeekTo(JNIEnv*, jobject obj, jint msec); |
| 52 void Play(JNIEnv*, jobject obj); | 59 void Play(JNIEnv*, jobject obj); |
| 53 void Pause(JNIEnv*, jobject obj); | 60 void Pause(JNIEnv*, jobject obj); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 void OnPlaybackComplete(); | 71 void OnPlaybackComplete(); |
| 65 | 72 |
| 66 private: | 73 private: |
| 67 // Object that manages the fullscreen media player. It is responsible for | 74 // Object that manages the fullscreen media player. It is responsible for |
| 68 // handling all the playback controls. | 75 // handling all the playback controls. |
| 69 MediaPlayerManagerAndroid* manager_; | 76 MediaPlayerManagerAndroid* manager_; |
| 70 | 77 |
| 71 // Reference to the Java object. | 78 // Reference to the Java object. |
| 72 base::android::ScopedJavaGlobalRef<jobject> j_content_video_view_; | 79 base::android::ScopedJavaGlobalRef<jobject> j_content_video_view_; |
| 73 | 80 |
| 81 int personality_; |
| 82 |
| 74 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); | 83 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); |
| 75 }; | 84 }; |
| 76 | 85 |
| 77 } // namespace content | 86 } // namespace content |
| 78 | 87 |
| 79 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 88 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| OLD | NEW |