| 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/browser/media/android/browser_media_player_manager.h" | 5 #include "content/browser/media/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include "base/android/scoped_java_ref.h" | 7 #include "base/android/scoped_java_ref.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "content/browser/android/content_view_core_impl.h" | 9 #include "content/browser/android/content_view_core_impl.h" |
| 10 #include "content/browser/media/android/browser_demuxer_android.h" | 10 #include "content/browser/media/android/browser_demuxer_android.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 weak_ptr_factory_(this) { | 128 weak_ptr_factory_(this) { |
| 129 } | 129 } |
| 130 | 130 |
| 131 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { | 131 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { |
| 132 // During the tear down process, OnDestroyPlayer() may or may not be called | 132 // During the tear down process, OnDestroyPlayer() may or may not be called |
| 133 // (e.g. the WebContents may be destroyed before the render process). So | 133 // (e.g. the WebContents may be destroyed before the render process). So |
| 134 // we cannot DCHECK(players_.empty()) here. Instead, all media players in | 134 // we cannot DCHECK(players_.empty()) here. Instead, all media players in |
| 135 // |players_| will be destroyed here because |player_| is a ScopedVector. | 135 // |players_| will be destroyed here because |player_| is a ScopedVector. |
| 136 } | 136 } |
| 137 | 137 |
| 138 void BrowserMediaPlayerManager::FullscreenPlayerPlay() { | |
| 139 MediaPlayerAndroid* player = GetFullscreenPlayer(); | |
| 140 if (player) { | |
| 141 if (fullscreen_player_is_released_) { | |
| 142 video_view_->OpenVideo(); | |
| 143 fullscreen_player_is_released_ = false; | |
| 144 } | |
| 145 player->Start(); | |
| 146 Send(new MediaPlayerMsg_DidMediaPlayerPlay(RoutingID(), | |
| 147 fullscreen_player_id_)); | |
| 148 } | |
| 149 } | |
| 150 | |
| 151 void BrowserMediaPlayerManager::FullscreenPlayerPause() { | |
| 152 MediaPlayerAndroid* player = GetFullscreenPlayer(); | |
| 153 if (player) { | |
| 154 player->Pause(true); | |
| 155 Send(new MediaPlayerMsg_DidMediaPlayerPause(RoutingID(), | |
| 156 fullscreen_player_id_)); | |
| 157 } | |
| 158 } | |
| 159 | |
| 160 void BrowserMediaPlayerManager::FullscreenPlayerSeek(int msec) { | |
| 161 MediaPlayerAndroid* player = GetFullscreenPlayer(); | |
| 162 if (player) { | |
| 163 // TODO(kbalazs): if |fullscreen_player_is_released_| is true | |
| 164 // at this point, player->GetCurrentTime() will be wrong until | |
| 165 // FullscreenPlayerPlay (http://crbug.com/322798). | |
| 166 OnSeekRequest(fullscreen_player_id_, | |
| 167 base::TimeDelta::FromMilliseconds(msec)); | |
| 168 } | |
| 169 } | |
| 170 | |
| 171 void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) { | 138 void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) { |
| 172 if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) | 139 if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) |
| 173 delegate->ToggleFullscreenModeForTab(web_contents_, false); | 140 delegate->ToggleFullscreenModeForTab(web_contents_, false); |
| 174 if (RenderWidgetHostViewAndroid* view_android = | 141 if (RenderWidgetHostViewAndroid* view_android = |
| 175 static_cast<RenderWidgetHostViewAndroid*>( | 142 static_cast<RenderWidgetHostViewAndroid*>( |
| 176 web_contents_->GetRenderWidgetHostView())) { | 143 web_contents_->GetRenderWidgetHostView())) { |
| 177 view_android->SetOverlayVideoMode(false); | 144 view_android->SetOverlayVideoMode(false); |
| 178 } | 145 } |
| 179 | 146 |
| 180 Send( | 147 Send( |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 562 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
| 596 #endif // defined(VIDEO_HOLE) | 563 #endif // defined(VIDEO_HOLE) |
| 597 } | 564 } |
| 598 | 565 |
| 599 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { | 566 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { |
| 600 player->Release(); | 567 player->Release(); |
| 601 ReleaseMediaResources(player->player_id()); | 568 ReleaseMediaResources(player->player_id()); |
| 602 } | 569 } |
| 603 | 570 |
| 604 } // namespace content | 571 } // namespace content |
| OLD | NEW |