Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 2440563004: Switch to using an explicit ended signal instead of time comparison. (Closed)
Patch Set: Fix tests. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 if (need_to_signal_duration_changed) 709 if (need_to_signal_duration_changed)
710 client_->durationChanged(); 710 client_->durationChanged();
711 } 711 }
712 712
713 void WebMediaPlayerAndroid::OnPlaybackComplete() { 713 void WebMediaPlayerAndroid::OnPlaybackComplete() {
714 // When playback is about to finish, android media player often stops 714 // When playback is about to finish, android media player often stops
715 // at a time which is smaller than the duration. This makes webkit never 715 // at a time which is smaller than the duration. This makes webkit never
716 // know that the playback has finished. To solve this, we set the 716 // know that the playback has finished. To solve this, we set the
717 // current time to media duration when OnPlaybackComplete() get called. 717 // current time to media duration when OnPlaybackComplete() get called.
718 interpolator_.SetBounds(duration_, duration_, default_tick_clock_.NowTicks()); 718 interpolator_.SetBounds(duration_, duration_, default_tick_clock_.NowTicks());
719 client_->timeChanged(); 719 client_->timeChanged(true);
720 720
721 // If the loop attribute is set, timeChanged() will update the current time 721 // If the loop attribute is set, timeChanged() will update the current time
722 // to 0. It will perform a seek to 0. Issue a command to the player to start 722 // to 0. It will perform a seek to 0. Issue a command to the player to start
723 // playing after seek completes. 723 // playing after seek completes.
724 if (is_playing_ && seeking_ && seek_time_.is_zero()) 724 if (is_playing_ && seeking_ && seek_time_.is_zero())
725 player_manager_->Start(player_id_); 725 player_manager_->Start(player_id_);
726 else 726 else
727 playback_completed_ = true; 727 playback_completed_ = true;
728 } 728 }
729 729
(...skipping 20 matching lines...) Expand all
750 if (pending_seek_) { 750 if (pending_seek_) {
751 pending_seek_ = false; 751 pending_seek_ = false;
752 seek(pending_seek_time_.InSecondsF()); 752 seek(pending_seek_time_.InSecondsF());
753 return; 753 return;
754 } 754 }
755 interpolator_.SetBounds(current_time, current_time, 755 interpolator_.SetBounds(current_time, current_time,
756 default_tick_clock_.NowTicks()); 756 default_tick_clock_.NowTicks());
757 757
758 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 758 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
759 759
760 client_->timeChanged(); 760 client_->timeChanged(playback_completed_);
761 } 761 }
762 762
763 void WebMediaPlayerAndroid::OnMediaError(int error_type) { 763 void WebMediaPlayerAndroid::OnMediaError(int error_type) {
764 switch (error_type) { 764 switch (error_type) {
765 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT: 765 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT:
766 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError); 766 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError);
767 break; 767 break;
768 case MediaPlayerAndroid::MEDIA_ERROR_DECODE: 768 case MediaPlayerAndroid::MEDIA_ERROR_DECODE:
769 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError); 769 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError);
770 break; 770 break;
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1333 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1334 switches::kDisableMediaSuspend)) { 1334 switches::kDisableMediaSuspend)) {
1335 return false; 1335 return false;
1336 } 1336 }
1337 1337
1338 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) && 1338 return base::FeatureList::IsEnabled(media::kResumeBackgroundVideo) &&
1339 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden(); 1339 hasAudio() && !isRemote() && delegate_ && delegate_->IsHidden();
1340 } 1340 }
1341 1341
1342 } // namespace content 1342 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/webmediaplayer_ms_unittest.cc » ('j') | media/filters/ffmpeg_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698