| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 160 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
| 161 if (player && player->IsPlayerReady()) { | 161 if (player && player->IsPlayerReady()) { |
| 162 Java_ContentVideoView_onUpdateMediaMetadata( | 162 Java_ContentVideoView_onUpdateMediaMetadata( |
| 163 env, content_video_view.obj(), player->GetVideoWidth(), | 163 env, content_video_view.obj(), player->GetVideoWidth(), |
| 164 player->GetVideoHeight(), | 164 player->GetVideoHeight(), |
| 165 static_cast<int>(player->GetDuration().InMilliseconds()), | 165 static_cast<int>(player->GetDuration().InMilliseconds()), |
| 166 player->CanPause(),player->CanSeekForward(), player->CanSeekBackward()); | 166 player->CanPause(),player->CanSeekForward(), player->CanSeekBackward()); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const { | |
| 171 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | |
| 172 return player ? player->GetVideoWidth() : 0; | |
| 173 } | |
| 174 | |
| 175 int ContentVideoView::GetVideoHeight(JNIEnv*, jobject obj) const { | |
| 176 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | |
| 177 return player ? player->GetVideoHeight() : 0; | |
| 178 } | |
| 179 | |
| 180 int ContentVideoView::GetDurationInMilliSeconds(JNIEnv*, jobject obj) const { | |
| 181 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | |
| 182 return player ? player->GetDuration().InMilliseconds() : -1; | |
| 183 } | |
| 184 | |
| 185 int ContentVideoView::GetCurrentPosition(JNIEnv*, jobject obj) const { | |
| 186 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | |
| 187 return player ? player->GetCurrentTime().InMilliseconds() : 0; | |
| 188 } | |
| 189 | |
| 190 bool ContentVideoView::IsPlaying(JNIEnv*, jobject obj) { | 170 bool ContentVideoView::IsPlaying(JNIEnv*, jobject obj) { |
| 191 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 171 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
| 192 return player ? player->IsPlaying() : false; | 172 return player ? player->IsPlaying() : false; |
| 193 } | 173 } |
| 194 | 174 |
| 195 void ContentVideoView::SeekTo(JNIEnv*, jobject obj, jint msec) { | |
| 196 manager_->FullscreenPlayerSeek(msec); | |
| 197 } | |
| 198 | |
| 199 void ContentVideoView::Play(JNIEnv*, jobject obj) { | |
| 200 manager_->FullscreenPlayerPlay(); | |
| 201 } | |
| 202 | |
| 203 void ContentVideoView::Pause(JNIEnv*, jobject obj) { | |
| 204 manager_->FullscreenPlayerPause(); | |
| 205 } | |
| 206 | |
| 207 void ContentVideoView::ExitFullscreen( | 175 void ContentVideoView::ExitFullscreen( |
| 208 JNIEnv*, jobject, jboolean release_media_player) { | 176 JNIEnv*, jobject, jboolean release_media_player) { |
| 209 j_content_video_view_.reset(); | 177 j_content_video_view_.reset(); |
| 210 manager_->ExitFullscreen(release_media_player); | 178 manager_->ExitFullscreen(release_media_player); |
| 211 } | 179 } |
| 212 | 180 |
| 213 void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, | 181 void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, |
| 214 jobject surface) { | 182 jobject surface) { |
| 215 manager_->SetVideoSurface( | 183 manager_->SetVideoSurface( |
| 216 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); | 184 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 231 ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore(); | 199 ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore(); |
| 232 JNIEnv* env = AttachCurrentThread(); | 200 JNIEnv* env = AttachCurrentThread(); |
| 233 return JavaObjectWeakGlobalRef( | 201 return JavaObjectWeakGlobalRef( |
| 234 env, | 202 env, |
| 235 Java_ContentVideoView_createContentVideoView( | 203 Java_ContentVideoView_createContentVideoView( |
| 236 env, | 204 env, |
| 237 content_view_core->GetJavaObject().obj(), | 205 content_view_core->GetJavaObject().obj(), |
| 238 reinterpret_cast<intptr_t>(this)).obj()); | 206 reinterpret_cast<intptr_t>(this)).obj()); |
| 239 } | 207 } |
| 240 } // namespace content | 208 } // namespace content |
| OLD | NEW |