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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 // know that the playback has finished. To solve this, we set the | 759 // know that the playback has finished. To solve this, we set the |
760 // current time to media duration when OnPlaybackComplete() get called. | 760 // current time to media duration when OnPlaybackComplete() get called. |
761 interpolator_.SetBounds(duration_, duration_); | 761 interpolator_.SetBounds(duration_, duration_); |
762 client_->timeChanged(); | 762 client_->timeChanged(); |
763 | 763 |
764 // if the loop attribute is set, timeChanged() will update the current time | 764 // if the loop attribute is set, timeChanged() will update the current time |
765 // to 0. It will perform a seek to 0. As the requests to the renderer | 765 // to 0. It will perform a seek to 0. As the requests to the renderer |
766 // process are sequential, the OnSeekComplete() will only occur | 766 // process are sequential, the OnSeekComplete() will only occur |
767 // once OnPlaybackComplete() is done. As the playback can only be executed | 767 // once OnPlaybackComplete() is done. As the playback can only be executed |
768 // upon completion of OnSeekComplete(), the request needs to be saved. | 768 // upon completion of OnSeekComplete(), the request needs to be saved. |
769 is_playing_ = false; | 769 UpdatePlayingState(false); |
qinmin
2014/09/16 17:28:24
you can just remove this statement, it does nothin
DaleCurtis
2014/09/16 17:30:27
I'm not sure about that. If the element is set to
| |
770 if (seeking_ && seek_time_ == base::TimeDelta()) | 770 if (seeking_ && seek_time_ == base::TimeDelta()) |
771 pending_playback_ = true; | 771 pending_playback_ = true; |
772 } | 772 } |
773 | 773 |
774 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) { | 774 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) { |
775 buffered_[0].end = has_valid_metadata_ ? duration() * percentage / 100 : 0; | 775 buffered_[0].end = has_valid_metadata_ ? duration() * percentage / 100 : 0; |
776 did_loading_progress_ = true; | 776 did_loading_progress_ = true; |
777 } | 777 } |
778 | 778 |
779 void WebMediaPlayerAndroid::OnSeekRequest(const base::TimeDelta& time_to_seek) { | 779 void WebMediaPlayerAndroid::OnSeekRequest(const base::TimeDelta& time_to_seek) { |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1301 | 1301 |
1302 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { | 1302 void WebMediaPlayerAndroid::SetNeedsEstablishPeer(bool needs_establish_peer) { |
1303 needs_establish_peer_ = needs_establish_peer; | 1303 needs_establish_peer_ = needs_establish_peer; |
1304 } | 1304 } |
1305 | 1305 |
1306 void WebMediaPlayerAndroid::setPoster(const blink::WebURL& poster) { | 1306 void WebMediaPlayerAndroid::setPoster(const blink::WebURL& poster) { |
1307 player_manager_->SetPoster(player_id_, poster); | 1307 player_manager_->SetPoster(player_id_, poster); |
1308 } | 1308 } |
1309 | 1309 |
1310 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { | 1310 void WebMediaPlayerAndroid::UpdatePlayingState(bool is_playing) { |
1311 const bool was_playing = is_playing_; | 1311 if (is_playing == is_playing_) |
1312 return; | |
1313 | |
1312 is_playing_ = is_playing; | 1314 is_playing_ = is_playing; |
1313 if (!delegate_ || was_playing == is_playing_) | 1315 |
1314 return; | |
1315 if (is_playing) | 1316 if (is_playing) |
1316 interpolator_.StartInterpolating(); | 1317 interpolator_.StartInterpolating(); |
1317 else | 1318 else |
1318 interpolator_.StopInterpolating(); | 1319 interpolator_.StopInterpolating(); |
1319 if (is_playing) | 1320 |
1320 delegate_->DidPlay(this); | 1321 if (delegate_) { |
qinmin
2014/09/16 17:28:24
Thanks for fixing my mistake here.
I remember i pu
| |
1321 else | 1322 if (is_playing) |
1322 delegate_->DidPause(this); | 1323 delegate_->DidPlay(this); |
1324 else | |
1325 delegate_->DidPause(this); | |
1326 } | |
1323 } | 1327 } |
1324 | 1328 |
1325 #if defined(VIDEO_HOLE) | 1329 #if defined(VIDEO_HOLE) |
1326 bool WebMediaPlayerAndroid::UpdateBoundaryRectangle() { | 1330 bool WebMediaPlayerAndroid::UpdateBoundaryRectangle() { |
1327 if (!video_weblayer_) | 1331 if (!video_weblayer_) |
1328 return false; | 1332 return false; |
1329 | 1333 |
1330 // Compute the geometry of video frame layer. | 1334 // Compute the geometry of video frame layer. |
1331 cc::Layer* layer = video_weblayer_->layer(); | 1335 cc::Layer* layer = video_weblayer_->layer(); |
1332 gfx::RectF rect(layer->bounds()); | 1336 gfx::RectF rect(layer->bounds()); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1793 | 1797 |
1794 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1798 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1795 std::string mime; | 1799 std::string mime; |
1796 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1800 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1797 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1801 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1798 return false; | 1802 return false; |
1799 return !mime.compare("application/x-mpegurl"); | 1803 return !mime.compare("application/x-mpegurl"); |
1800 } | 1804 } |
1801 | 1805 |
1802 } // namespace content | 1806 } // namespace content |
OLD | NEW |