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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (success) | 745 if (success) |
746 OnVideoSizeChanged(width, height); | 746 OnVideoSizeChanged(width, height); |
747 | 747 |
748 has_valid_metadata_ = success; | 748 has_valid_metadata_ = success; |
749 | 749 |
750 if (need_to_signal_duration_changed) | 750 if (need_to_signal_duration_changed) |
751 client_->durationChanged(); | 751 client_->durationChanged(); |
752 } | 752 } |
753 | 753 |
754 void WebMediaPlayerAndroid::OnPlaybackComplete() { | 754 void WebMediaPlayerAndroid::OnPlaybackComplete() { |
755 // When playback is about to finish, android media player often stops | |
756 // at a time which is smaller than the duration. This makes webkit never | |
757 // know that the playback has finished. To solve this, we set the | |
758 // current time to media duration when OnPlaybackComplete() get called. | |
759 interpolator_.SetBounds(duration_, duration_); | 755 interpolator_.SetBounds(duration_, duration_); |
760 client_->timeChanged(); | 756 // If the duration in the metadata is not correct, then actual duration should |
| 757 // be updated in blink. |
| 758 if (duration() != currentTime()) |
| 759 OnDurationChanged(base::FromSecondsD(currentTime())); |
761 | 760 |
762 // if the loop attribute is set, timeChanged() will update the current time | 761 client_->mediaEnded(); |
| 762 |
| 763 // If the 'loop' attribute is set, mediaEnded() will update the current time |
763 // to 0. It will perform a seek to 0. As the requests to the renderer | 764 // to 0. It will perform a seek to 0. As the requests to the renderer |
764 // process are sequential, the OnSeekComplete() will only occur | 765 // process are sequential, the OnSeekComplete() will only occur |
765 // once OnPlaybackComplete() is done. As the playback can only be executed | 766 // once OnPlaybackComplete() is done. As the playback can only be executed |
766 // upon completion of OnSeekComplete(), the request needs to be saved. | 767 // upon completion of OnSeekComplete(), the request needs to be saved. |
767 is_playing_ = false; | 768 is_playing_ = false; |
768 if (seeking_ && seek_time_ == base::TimeDelta()) | 769 if (seeking_ && seek_time_ == base::TimeDelta()) |
769 pending_playback_ = true; | 770 pending_playback_ = true; |
770 } | 771 } |
771 | 772 |
772 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) { | 773 void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) { |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 | 1792 |
1792 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1793 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1793 std::string mime; | 1794 std::string mime; |
1794 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1795 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1795 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1796 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1796 return false; | 1797 return false; |
1797 return !mime.compare("application/x-mpegurl"); | 1798 return !mime.compare("application/x-mpegurl"); |
1798 } | 1799 } |
1799 | 1800 |
1800 } // namespace content | 1801 } // namespace content |
OLD | NEW |