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 "media/base/android/media_player_bridge.h" | 5 #include "media/base/android/media_player_bridge.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 JNIEnv* env = base::android::AttachCurrentThread(); | 383 JNIEnv* env = base::android::AttachCurrentThread(); |
384 Java_MediaPlayerBridge_pause(env, j_media_player_bridge_.obj()); | 384 Java_MediaPlayerBridge_pause(env, j_media_player_bridge_.obj()); |
385 time_update_timer_.Stop(); | 385 time_update_timer_.Stop(); |
386 } | 386 } |
387 | 387 |
388 void MediaPlayerBridge::PendingSeekInternal(base::TimeDelta time) { | 388 void MediaPlayerBridge::PendingSeekInternal(base::TimeDelta time) { |
389 SeekInternal(time); | 389 SeekInternal(time); |
390 } | 390 } |
391 | 391 |
392 void MediaPlayerBridge::SeekInternal(base::TimeDelta time) { | 392 void MediaPlayerBridge::SeekInternal(base::TimeDelta time) { |
| 393 if (time > duration_) |
| 394 time = duration_; |
| 395 |
| 396 // Seeking to an invalid position may cause media player to stuck in an |
| 397 // error state. |
| 398 if (time < base::TimeDelta()) { |
| 399 DCHECK_EQ(-1.0, time.InMillisecondsF()); |
| 400 return; |
| 401 } |
| 402 |
393 JNIEnv* env = base::android::AttachCurrentThread(); | 403 JNIEnv* env = base::android::AttachCurrentThread(); |
394 CHECK(env); | 404 CHECK(env); |
395 | 405 |
396 int time_msec = static_cast<int>(time.InMilliseconds()); | 406 int time_msec = static_cast<int>(time.InMilliseconds()); |
397 Java_MediaPlayerBridge_seekTo( | 407 Java_MediaPlayerBridge_seekTo( |
398 env, j_media_player_bridge_.obj(), time_msec); | 408 env, j_media_player_bridge_.obj(), time_msec); |
399 } | 409 } |
400 | 410 |
401 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { | 411 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { |
402 bool ret = RegisterNativesImpl(env); | 412 bool ret = RegisterNativesImpl(env); |
(...skipping 19 matching lines...) Expand all Loading... |
422 | 432 |
423 GURL MediaPlayerBridge::GetUrl() { | 433 GURL MediaPlayerBridge::GetUrl() { |
424 return url_; | 434 return url_; |
425 } | 435 } |
426 | 436 |
427 GURL MediaPlayerBridge::GetFirstPartyForCookies() { | 437 GURL MediaPlayerBridge::GetFirstPartyForCookies() { |
428 return first_party_for_cookies_; | 438 return first_party_for_cookies_; |
429 } | 439 } |
430 | 440 |
431 } // namespace media | 441 } // namespace media |
OLD | NEW |