OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 if (need_to_signal_duration_changed) | 707 if (need_to_signal_duration_changed) |
708 client_->durationChanged(); | 708 client_->durationChanged(); |
709 } | 709 } |
710 | 710 |
711 void WebMediaPlayerAndroid::OnPlaybackComplete() { | 711 void WebMediaPlayerAndroid::OnPlaybackComplete() { |
712 // When playback is about to finish, android media player often stops | 712 // When playback is about to finish, android media player often stops |
713 // at a time which is smaller than the duration. This makes webkit never | 713 // at a time which is smaller than the duration. This makes webkit never |
714 // know that the playback has finished. To solve this, we set the | 714 // know that the playback has finished. To solve this, we set the |
715 // current time to media duration when OnPlaybackComplete() get called. | 715 // current time to media duration when OnPlaybackComplete() get called. |
716 interpolator_.SetBounds(duration_, duration_, default_tick_clock_.NowTicks()); | 716 interpolator_.SetBounds(duration_, duration_, default_tick_clock_.NowTicks()); |
717 client_->timeChanged(); | 717 client_->timeChanged(true); |
718 | 718 |
719 // If the loop attribute is set, timeChanged() will update the current time | 719 // If the loop attribute is set, timeChanged() will update the current time |
720 // to 0. It will perform a seek to 0. Issue a command to the player to start | 720 // to 0. It will perform a seek to 0. Issue a command to the player to start |
721 // playing after seek completes. | 721 // playing after seek completes. |
722 if (is_playing_ && seeking_ && seek_time_.is_zero()) | 722 if (is_playing_ && seeking_ && seek_time_.is_zero()) |
723 player_manager_->Start(player_id_); | 723 player_manager_->Start(player_id_); |
724 else | 724 else |
725 playback_completed_ = true; | 725 playback_completed_ = true; |
726 } | 726 } |
727 | 727 |
(...skipping 20 matching lines...) Expand all Loading... |
748 if (pending_seek_) { | 748 if (pending_seek_) { |
749 pending_seek_ = false; | 749 pending_seek_ = false; |
750 seek(pending_seek_time_.InSecondsF()); | 750 seek(pending_seek_time_.InSecondsF()); |
751 return; | 751 return; |
752 } | 752 } |
753 interpolator_.SetBounds(current_time, current_time, | 753 interpolator_.SetBounds(current_time, current_time, |
754 default_tick_clock_.NowTicks()); | 754 default_tick_clock_.NowTicks()); |
755 | 755 |
756 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 756 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
757 | 757 |
758 client_->timeChanged(); | 758 client_->timeChanged(playback_completed_); |
759 } | 759 } |
760 | 760 |
761 void WebMediaPlayerAndroid::OnMediaError(int error_type) { | 761 void WebMediaPlayerAndroid::OnMediaError(int error_type) { |
762 switch (error_type) { | 762 switch (error_type) { |
763 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT: | 763 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT: |
764 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError); | 764 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError); |
765 break; | 765 break; |
766 case MediaPlayerAndroid::MEDIA_ERROR_DECODE: | 766 case MediaPlayerAndroid::MEDIA_ERROR_DECODE: |
767 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError); | 767 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError); |
768 break; | 768 break; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1322 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1323 switches::kDisableMediaSuspend)) { | 1323 switches::kDisableMediaSuspend)) { |
1324 return false; | 1324 return false; |
1325 } | 1325 } |
1326 | 1326 |
1327 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && | 1327 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && |
1328 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); | 1328 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); |
1329 } | 1329 } |
1330 | 1330 |
1331 } // namespace content | 1331 } // namespace content |
OLD | NEW |