Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: media/base/android/media_player_android.cc

Issue 643353002: Listen to the audio focus event for MSE/EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/android/media_player_android.h ('k') | media/base/android/media_player_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "media/base/android/media_player_android.h" 5 #include "media/base/android/media_player_android.h"
6 6
7 #include "base/android/jni_android.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h"
8 #include "media/base/android/media_drm_bridge.h" 10 #include "media/base/android/media_drm_bridge.h"
9 #include "media/base/android/media_player_manager.h" 11 #include "media/base/android/media_player_manager.h"
10 12
11 namespace media { 13 namespace media {
12 14
13 MediaPlayerAndroid::MediaPlayerAndroid( 15 MediaPlayerAndroid::MediaPlayerAndroid(
14 int player_id, 16 int player_id,
15 MediaPlayerManager* manager, 17 MediaPlayerManager* manager,
16 const RequestMediaResourcesCB& request_media_resources_cb, 18 const RequestMediaResourcesCB& request_media_resources_cb,
17 const GURL& frame_url) 19 const GURL& frame_url)
18 : request_media_resources_cb_(request_media_resources_cb), 20 : request_media_resources_cb_(request_media_resources_cb),
19 player_id_(player_id), 21 player_id_(player_id),
20 manager_(manager), 22 manager_(manager),
21 frame_url_(frame_url) { 23 frame_url_(frame_url),
24 weak_factory_(this) {
25 listener_.reset(new MediaPlayerListener(base::MessageLoopProxy::current(),
26 weak_factory_.GetWeakPtr()));
22 } 27 }
23 28
24 MediaPlayerAndroid::~MediaPlayerAndroid() {} 29 MediaPlayerAndroid::~MediaPlayerAndroid() {}
25 30
26 GURL MediaPlayerAndroid::GetUrl() { 31 GURL MediaPlayerAndroid::GetUrl() {
27 return GURL(); 32 return GURL();
28 } 33 }
29 34
30 GURL MediaPlayerAndroid::GetFirstPartyForCookies() { 35 GURL MediaPlayerAndroid::GetFirstPartyForCookies() {
31 return GURL(); 36 return GURL();
32 } 37 }
33 38
34 void MediaPlayerAndroid::SetCdm(BrowserCdm* /* cdm */) { 39 void MediaPlayerAndroid::SetCdm(BrowserCdm* /* cdm */) {
35 // Players that support EME should override this. 40 // Players that support EME should override this.
36 NOTREACHED() << "EME not supported on base MediaPlayerAndroid class."; 41 NOTREACHED() << "EME not supported on base MediaPlayerAndroid class.";
37 return; 42 return;
38 } 43 }
39 44
45 void MediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
46 manager_->OnVideoSizeChanged(player_id(), width, height);
47 }
48
49 void MediaPlayerAndroid::OnMediaError(int error_type) {
50 manager_->OnError(player_id(), error_type);
51 }
52
53 void MediaPlayerAndroid::OnBufferingUpdate(int percent) {
54 manager_->OnBufferingUpdate(player_id(), percent);
55 }
56
57 void MediaPlayerAndroid::OnPlaybackComplete() {
58 manager_->OnPlaybackComplete(player_id());
59 }
60
61 void MediaPlayerAndroid::OnMediaInterrupted() {
62 manager_->OnMediaInterrupted(player_id());
63 }
64
65 void MediaPlayerAndroid::OnSeekComplete() {
66 manager_->OnSeekComplete(player_id(), GetCurrentTime());
67 }
68
69 void MediaPlayerAndroid::OnMediaPrepared() {}
70
71 void MediaPlayerAndroid::AttachListener(jobject j_media_player) {
72 jobject j_context = base::android::GetApplicationContext();
73 DCHECK(j_context);
74
75 listener_->CreateMediaPlayerListener(j_context, j_media_player);
76 }
77
78 void MediaPlayerAndroid::DetachListener() {
79 listener_->ReleaseMediaPlayerListenerResources();
80 }
81
82
40 } // namespace media 83 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_player_android.h ('k') | media/base/android/media_player_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698