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 #include "content/browser/android/content_video_view.h" | 5 #include "content/browser/android/content_video_view.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/browser/android/media_player_manager_android.h" | 10 #include "content/browser/android/media_player_manager_android.h" |
11 #include "content/common/android/surface_callback.h" | 11 #include "content/common/android/surface_callback.h" |
12 #include "content/common/android/surface_texture_peer.h" | 12 #include "content/common/android/surface_texture_peer.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
15 #include "jni/ContentVideoView_jni.h" | 15 #include "jni/ContentVideoView_jni.h" |
16 | 16 |
17 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
18 using base::android::CheckException; | 18 using base::android::CheckException; |
19 using base::android::ScopedJavaGlobalRef; | 19 using base::android::ScopedJavaGlobalRef; |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { | 23 bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { |
24 return RegisterNativesImpl(env); | 24 return RegisterNativesImpl(env); |
25 } | 25 } |
26 | 26 |
27 ContentVideoView::ContentVideoView(MediaPlayerManagerAndroid* manager) | 27 ContentVideoView::ContentVideoView(MediaPlayerManagerAndroid* manager) |
28 : manager_(manager) { | 28 : manager_(manager), personality_(PERSONALITY_FULL_SCREEN) { |
29 } | 29 } |
30 | 30 |
31 ContentVideoView::~ContentVideoView() { | 31 ContentVideoView::~ContentVideoView() { |
32 DestroyContentVideoView(); | 32 DestroyContentVideoView(); |
33 } | 33 } |
34 | 34 |
35 void ContentVideoView::CreateContentVideoView() { | 35 void ContentVideoView::CreateContentVideoView(int personality) { |
36 if (!j_content_video_view_.is_null() && personality_ != personality) { | |
qinmin
2012/12/17 19:34:06
is this going to support both playing an embedded
wonsik2
2013/02/14 14:56:38
Do you think having a separate class/SurfaceView f
| |
37 DestroyContentVideoView(); | |
38 } | |
39 personality_ = personality; | |
36 if (j_content_video_view_.is_null()) { | 40 if (j_content_video_view_.is_null()) { |
37 JNIEnv* env = AttachCurrentThread(); | 41 JNIEnv* env = AttachCurrentThread(); |
38 j_content_video_view_.Reset(Java_ContentVideoView_createContentVideoView( | 42 j_content_video_view_.Reset(Java_ContentVideoView_createContentVideoView( |
39 env, reinterpret_cast<jint>(this))); | 43 env, reinterpret_cast<jint>(this), static_cast<jint>(personality))); |
40 } else { | 44 } else { |
41 // Just ask video view to reopen the video. | 45 // Just ask video view to reopen the video. |
42 Java_ContentVideoView_openVideo(AttachCurrentThread(), | 46 Java_ContentVideoView_openVideo(AttachCurrentThread(), |
43 j_content_video_view_.obj()); | 47 j_content_video_view_.obj()); |
44 } | 48 } |
45 } | 49 } |
46 | 50 |
47 void ContentVideoView::DestroyContentVideoView() { | 51 void ContentVideoView::DestroyContentVideoView() { |
48 if (!j_content_video_view_.is_null()) { | 52 if (!j_content_video_view_.is_null()) { |
49 Java_ContentVideoView_destroyContentVideoView(AttachCurrentThread()); | 53 Java_ContentVideoView_destroyContentVideoView(AttachCurrentThread()); |
(...skipping 26 matching lines...) Expand all Loading... | |
76 } | 80 } |
77 } | 81 } |
78 | 82 |
79 void ContentVideoView::OnPlaybackComplete() { | 83 void ContentVideoView::OnPlaybackComplete() { |
80 if (!j_content_video_view_.is_null()) { | 84 if (!j_content_video_view_.is_null()) { |
81 Java_ContentVideoView_onPlaybackComplete(AttachCurrentThread(), | 85 Java_ContentVideoView_onPlaybackComplete(AttachCurrentThread(), |
82 j_content_video_view_.obj()); | 86 j_content_video_view_.obj()); |
83 } | 87 } |
84 } | 88 } |
85 | 89 |
90 int ContentVideoView::getPersonality() { | |
91 return personality_; | |
92 } | |
93 | |
86 void ContentVideoView::UpdateMediaMetadata() { | 94 void ContentVideoView::UpdateMediaMetadata() { |
87 if (!j_content_video_view_.is_null()) | 95 if (!j_content_video_view_.is_null()) |
88 UpdateMediaMetadata(AttachCurrentThread(), j_content_video_view_.obj()); | 96 UpdateMediaMetadata(AttachCurrentThread(), j_content_video_view_.obj()); |
89 } | 97 } |
90 | 98 |
91 int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const { | 99 int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const { |
92 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer(); | 100 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer(); |
93 return player ? player->GetVideoWidth() : 0; | 101 return player ? player->GetVideoWidth() : 0; |
94 } | 102 } |
95 | 103 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) { | 147 void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) { |
140 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer(); | 148 media::MediaPlayerBridge* player = manager_->GetFullscreenPlayer(); |
141 if (player && player->prepared()) | 149 if (player && player->prepared()) |
142 Java_ContentVideoView_updateMediaMetadata( | 150 Java_ContentVideoView_updateMediaMetadata( |
143 env, obj, player->GetVideoWidth(), player->GetVideoHeight(), | 151 env, obj, player->GetVideoWidth(), player->GetVideoHeight(), |
144 player->GetDuration().InMilliseconds(), player->can_pause(), | 152 player->GetDuration().InMilliseconds(), player->can_pause(), |
145 player->can_seek_forward(), player->can_seek_backward()); | 153 player->can_seek_forward(), player->can_seek_backward()); |
146 } | 154 } |
147 | 155 |
148 } // namespace content | 156 } // namespace content |
OLD | NEW |