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/android/media_players_observer.h" | 10 #include "content/browser/android/media_players_observer.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 int player_id, base::TimeDelta duration, int width, int height, | 278 int player_id, base::TimeDelta duration, int width, int height, |
279 bool success) { | 279 bool success) { |
280 Send(new MediaPlayerMsg_MediaMetadataChanged( | 280 Send(new MediaPlayerMsg_MediaMetadataChanged( |
281 RoutingID(), player_id, duration, width, height, success)); | 281 RoutingID(), player_id, duration, width, height, success)); |
282 if (fullscreen_player_id_ == player_id) | 282 if (fullscreen_player_id_ == player_id) |
283 video_view_->UpdateMediaMetadata(); | 283 video_view_->UpdateMediaMetadata(); |
284 } | 284 } |
285 | 285 |
286 void BrowserMediaPlayerManager::OnPlaybackComplete(int player_id) { | 286 void BrowserMediaPlayerManager::OnPlaybackComplete(int player_id) { |
287 Send(new MediaPlayerMsg_MediaPlaybackCompleted(RoutingID(), player_id)); | 287 Send(new MediaPlayerMsg_MediaPlaybackCompleted(RoutingID(), player_id)); |
| 288 |
288 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); | 289 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
289 | 290 |
290 if (fullscreen_player_id_ == player_id) | 291 if (fullscreen_player_id_ == player_id) |
291 video_view_->OnPlaybackComplete(); | 292 video_view_->OnPlaybackComplete(); |
292 } | 293 } |
293 | 294 |
294 void BrowserMediaPlayerManager::OnMediaInterrupted(int player_id) { | 295 void BrowserMediaPlayerManager::OnMediaInterrupted(int player_id) { |
295 // Tell WebKit that the audio should be paused, then release all resources | 296 // Tell WebKit that the audio should be paused, then release all resources |
296 Send(new MediaPlayerMsg_MediaPlayerReleased(RoutingID(), player_id)); | 297 Send(new MediaPlayerMsg_MediaPlayerReleased(RoutingID(), player_id)); |
297 OnReleaseResources(player_id); | 298 OnReleaseResources(player_id); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 player->SeekTo(time); | 575 player->SeekTo(time); |
575 } | 576 } |
576 | 577 |
577 void BrowserMediaPlayerManager::OnPause( | 578 void BrowserMediaPlayerManager::OnPause( |
578 int player_id, | 579 int player_id, |
579 bool is_media_related_action) { | 580 bool is_media_related_action) { |
580 MediaPlayerAndroid* player = GetPlayer(player_id); | 581 MediaPlayerAndroid* player = GetPlayer(player_id); |
581 if (player) | 582 if (player) |
582 player->Pause(is_media_related_action); | 583 player->Pause(is_media_related_action); |
583 | 584 |
584 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); | 585 if (is_media_related_action) |
| 586 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
585 } | 587 } |
586 | 588 |
587 void BrowserMediaPlayerManager::OnSetVolume(int player_id, double volume) { | 589 void BrowserMediaPlayerManager::OnSetVolume(int player_id, double volume) { |
588 MediaPlayerAndroid* player = GetPlayer(player_id); | 590 MediaPlayerAndroid* player = GetPlayer(player_id); |
589 if (player) | 591 if (player) |
590 player->SetVolume(volume); | 592 player->SetVolume(volume); |
591 } | 593 } |
592 | 594 |
593 void BrowserMediaPlayerManager::OnSetPoster(int player_id, const GURL& url) { | 595 void BrowserMediaPlayerManager::OnSetPoster(int player_id, const GURL& url) { |
594 // To be overridden by subclasses. | 596 // To be overridden by subclasses. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 700 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
699 #endif // defined(VIDEO_HOLE) | 701 #endif // defined(VIDEO_HOLE) |
700 } | 702 } |
701 | 703 |
702 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { | 704 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { |
703 player->Release(); | 705 player->Release(); |
704 ReleaseMediaResources(player->player_id()); | 706 ReleaseMediaResources(player->player_id()); |
705 } | 707 } |
706 | 708 |
707 } // namespace content | 709 } // namespace content |
OLD | NEW |