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

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

Issue 23442021: Add loop implementation for HTML5 Video on Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 3 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
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 has_media_metadata_(false), 90 has_media_metadata_(false),
91 has_media_info_(false), 91 has_media_info_(false),
92 stream_texture_factory_(factory), 92 stream_texture_factory_(factory),
93 needs_external_surface_(false), 93 needs_external_surface_(false),
94 video_frame_provider_client_(NULL), 94 video_frame_provider_client_(NULL),
95 #if defined(GOOGLE_TV) 95 #if defined(GOOGLE_TV)
96 external_surface_threshold_(-1), 96 external_surface_threshold_(-1),
97 demuxer_(NULL), 97 demuxer_(NULL),
98 media_stream_client_(NULL), 98 media_stream_client_(NULL),
99 #endif // defined(GOOGLE_TV) 99 #endif // defined(GOOGLE_TV)
100 pending_playback_(false),
100 player_type_(MEDIA_PLAYER_TYPE_URL), 101 player_type_(MEDIA_PLAYER_TYPE_URL),
101 proxy_(proxy), 102 proxy_(proxy),
102 current_time_(0), 103 current_time_(0),
103 media_log_(media_log) { 104 media_log_(media_log) {
104 DCHECK(proxy_); 105 DCHECK(proxy_);
105 DCHECK(manager_); 106 DCHECK(manager_);
106 107
107 // We want to be notified of |main_loop_| destruction. 108 // We want to be notified of |main_loop_| destruction.
108 base::MessageLoop::current()->AddDestructionObserver(this); 109 base::MessageLoop::current()->AddDestructionObserver(this);
109 110
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 client_->durationChanged(); 581 client_->durationChanged();
581 } 582 }
582 583
583 void WebMediaPlayerAndroid::OnPlaybackComplete() { 584 void WebMediaPlayerAndroid::OnPlaybackComplete() {
584 // When playback is about to finish, android media player often stops 585 // When playback is about to finish, android media player often stops
585 // at a time which is smaller than the duration. This makes webkit never 586 // at a time which is smaller than the duration. This makes webkit never
586 // know that the playback has finished. To solve this, we set the 587 // know that the playback has finished. To solve this, we set the
587 // current time to media duration when OnPlaybackComplete() get called. 588 // current time to media duration when OnPlaybackComplete() get called.
588 OnTimeUpdate(duration_); 589 OnTimeUpdate(duration_);
589 client_->timeChanged(); 590 client_->timeChanged();
591
592 // if the loop attribute is set, timeChanged() will update the current time
593 // to 0. It will perform a seek to 0. As the requests to the renderer
594 // process are sequential, the OnSeekCompelete() will only occur
595 // once OnPlaybackComplete() is done. As the playback can only be executed
596 // upon completion of OnSeekComplete(), the request needs to be saved.
597 is_playing_ = false;
598 if (seeking_ && pending_seek_ == 0)
599 pending_playback_ = true;
590 } 600 }
591 601
592 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) { 602 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) {
593 buffered_[0].end = duration() * percentage / 100; 603 buffered_[0].end = duration() * percentage / 100;
594 did_loading_progress_ = true; 604 did_loading_progress_ = true;
595 } 605 }
596 606
597 void WebMediaPlayerAndroid::OnSeekComplete(base::TimeDelta current_time) { 607 void WebMediaPlayerAndroid::OnSeekComplete(base::TimeDelta current_time) {
598 seeking_ = false; 608 seeking_ = false;
599 609
600 OnTimeUpdate(current_time); 610 OnTimeUpdate(current_time);
601 611
602 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 612 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
603 613
604 client_->timeChanged(); 614 client_->timeChanged();
615
616 if (pending_playback_) {
617 play();
618 pending_playback_ = false;
619 }
605 } 620 }
606 621
607 void WebMediaPlayerAndroid::OnMediaError(int error_type) { 622 void WebMediaPlayerAndroid::OnMediaError(int error_type) {
608 switch (error_type) { 623 switch (error_type) {
609 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT: 624 case MediaPlayerAndroid::MEDIA_ERROR_FORMAT:
610 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError); 625 UpdateNetworkState(WebMediaPlayer::NetworkStateFormatError);
611 break; 626 break;
612 case MediaPlayerAndroid::MEDIA_ERROR_DECODE: 627 case MediaPlayerAndroid::MEDIA_ERROR_DECODE:
613 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError); 628 UpdateNetworkState(WebMediaPlayer::NetworkStateDecodeError);
614 break; 629 break;
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1199
1185 void WebMediaPlayerAndroid::exitFullscreen() { 1200 void WebMediaPlayerAndroid::exitFullscreen() {
1186 proxy_->ExitFullscreen(player_id_); 1201 proxy_->ExitFullscreen(player_id_);
1187 } 1202 }
1188 1203
1189 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1204 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1190 return manager_->CanEnterFullscreen(frame_); 1205 return manager_->CanEnterFullscreen(frame_);
1191 } 1206 }
1192 1207
1193 } // namespace content 1208 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698