| 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 // already triggers a durationchanged event. If this is a different | 728 // already triggers a durationchanged event. If this is a different |
| 729 // transition, remember to signal durationchanged. | 729 // transition, remember to signal durationchanged. |
| 730 // Do not ever signal durationchanged on metadata change in MSE case | 730 // Do not ever signal durationchanged on metadata change in MSE case |
| 731 // because OnDurationChanged() handles this. | 731 // because OnDurationChanged() handles this. |
| 732 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && | 732 if (ready_state_ > WebMediaPlayer::ReadyStateHaveNothing && |
| 733 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { | 733 player_type_ != MEDIA_PLAYER_TYPE_MEDIA_SOURCE) { |
| 734 need_to_signal_duration_changed = true; | 734 need_to_signal_duration_changed = true; |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 | 737 |
| 738 // UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata) will trigger a |
| 739 // call to duration(), which checks |has_valid_metadata_|. so |
| 740 // |has_valid_metadata_| has to be updated before calling UpdateReadyState(). |
| 741 has_valid_metadata_ = success; |
| 738 if (ready_state_ != WebMediaPlayer::ReadyStateHaveEnoughData) { | 742 if (ready_state_ != WebMediaPlayer::ReadyStateHaveEnoughData) { |
| 739 UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 743 UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 740 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 744 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
| 741 } | 745 } |
| 742 | 746 |
| 743 // TODO(wolenetz): Should we just abort early and set network state to an | 747 // TODO(wolenetz): Should we just abort early and set network state to an |
| 744 // error if success == false? See http://crbug.com/248399 | 748 // error if success == false? See http://crbug.com/248399 |
| 745 if (success) | 749 if (success) |
| 746 OnVideoSizeChanged(width, height); | 750 OnVideoSizeChanged(width, height); |
| 747 | 751 |
| 748 has_valid_metadata_ = success; | |
| 749 | |
| 750 if (need_to_signal_duration_changed) | 752 if (need_to_signal_duration_changed) |
| 751 client_->durationChanged(); | 753 client_->durationChanged(); |
| 752 } | 754 } |
| 753 | 755 |
| 754 void WebMediaPlayerAndroid::OnPlaybackComplete() { | 756 void WebMediaPlayerAndroid::OnPlaybackComplete() { |
| 755 // When playback is about to finish, android media player often stops | 757 // 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 | 758 // 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 | 759 // know that the playback has finished. To solve this, we set the |
| 758 // current time to media duration when OnPlaybackComplete() get called. | 760 // current time to media duration when OnPlaybackComplete() get called. |
| 759 interpolator_.SetBounds(duration_, duration_); | 761 interpolator_.SetBounds(duration_, duration_); |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 | 1793 |
| 1792 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1794 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1793 std::string mime; | 1795 std::string mime; |
| 1794 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1796 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1795 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1797 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1796 return false; | 1798 return false; |
| 1797 return !mime.compare("application/x-mpegurl"); | 1799 return !mime.compare("application/x-mpegurl"); |
| 1798 } | 1800 } |
| 1799 | 1801 |
| 1800 } // namespace content | 1802 } // namespace content |
| OLD | NEW |