OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 package org.chromium.media; | 5 package org.chromium.media; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.media.MediaPlayer; | 8 import android.media.MediaPlayer; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 @CalledByNative("AllowedOperations") | 166 @CalledByNative("AllowedOperations") |
167 private boolean canSeekBackward() { return mCanSeekBackward; } | 167 private boolean canSeekBackward() { return mCanSeekBackward; } |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
171 * Returns an AllowedOperations object to show all the operations that are | 171 * Returns an AllowedOperations object to show all the operations that are |
172 * allowed on the media player. | 172 * allowed on the media player. |
173 */ | 173 */ |
174 @CalledByNative | 174 @CalledByNative |
175 private static AllowedOperations getAllowedOperations(MediaPlayer player) { | 175 private static AllowedOperations getAllowedOperations(MediaPlayerBridge brid
ge) { |
| 176 MediaPlayer player = bridge.getLocalPlayer(); |
176 boolean canPause = true; | 177 boolean canPause = true; |
177 boolean canSeekForward = true; | 178 boolean canSeekForward = true; |
178 boolean canSeekBackward = true; | 179 boolean canSeekBackward = true; |
179 try { | 180 try { |
180 Method getMetadata = player.getClass().getDeclaredMethod( | 181 Method getMetadata = player.getClass().getDeclaredMethod( |
181 "getMetadata", boolean.class, boolean.class); | 182 "getMetadata", boolean.class, boolean.class); |
182 getMetadata.setAccessible(true); | 183 getMetadata.setAccessible(true); |
183 Object data = getMetadata.invoke(player, false, false); | 184 Object data = getMetadata.invoke(player, false, false); |
184 if (data != null) { | 185 if (data != null) { |
185 Class<?> metadataClass = data.getClass(); | 186 Class<?> metadataClass = data.getClass(); |
(...skipping 19 matching lines...) Expand all Loading... |
205 } catch (InvocationTargetException e) { | 206 } catch (InvocationTargetException e) { |
206 Log.e(TAG, "Cannot invoke MediaPlayer.getMetadata() method: " + e); | 207 Log.e(TAG, "Cannot invoke MediaPlayer.getMetadata() method: " + e); |
207 } catch (IllegalAccessException e) { | 208 } catch (IllegalAccessException e) { |
208 Log.e(TAG, "Cannot access metadata: " + e); | 209 Log.e(TAG, "Cannot access metadata: " + e); |
209 } catch (NoSuchFieldException e) { | 210 } catch (NoSuchFieldException e) { |
210 Log.e(TAG, "Cannot find matching fields in Metadata class: " + e); | 211 Log.e(TAG, "Cannot find matching fields in Metadata class: " + e); |
211 } | 212 } |
212 return new AllowedOperations(canPause, canSeekForward, canSeekBackward); | 213 return new AllowedOperations(canPause, canSeekForward, canSeekBackward); |
213 } | 214 } |
214 } | 215 } |
OLD | NEW |