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 #include "media/base/android/media_player_bridge.h" | 5 #include "media/base/android/media_player_bridge.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 | 321 |
322 GetMetadata(); | 322 GetMetadata(); |
323 | 323 |
324 media_prepared_cb_.Run(player_id_, duration_); | 324 media_prepared_cb_.Run(player_id_, duration_); |
325 } | 325 } |
326 | 326 |
327 void MediaPlayerBridge::GetMetadata() { | 327 void MediaPlayerBridge::GetMetadata() { |
328 JNIEnv* env = AttachCurrentThread(); | 328 JNIEnv* env = AttachCurrentThread(); |
329 CHECK(env); | 329 CHECK(env); |
330 | 330 |
331 ScopedJavaLocalRef<jclass> media_player_class( | |
332 GetClass(env, "android/media/MediaPlayer")); | |
Yaron
2013/03/11 19:58:40
Sorry to do this to you, but since you're already
| |
333 jmethodID method = MethodID::Get<MethodID::TYPE_INSTANCE>( | 331 jmethodID method = MethodID::Get<MethodID::TYPE_INSTANCE>( |
334 env, media_player_class.obj(), "getMetadata", | 332 env, g_MediaPlayer_clazz, "getMetadata", |
335 "(ZZ)Landroid/media/Metadata;"); | 333 "(ZZ)Landroid/media/Metadata;"); |
336 ScopedJavaLocalRef<jobject> j_metadata( | 334 ScopedJavaLocalRef<jobject> j_metadata( |
337 env, env->CallObjectMethod( | 335 env, env->CallObjectMethod( |
338 j_media_player_.obj(), method, JNI_FALSE, JNI_FALSE)); | 336 j_media_player_.obj(), method, JNI_FALSE, JNI_FALSE)); |
339 CheckException(env); | 337 CheckException(env); |
340 if (j_metadata.is_null()) | 338 if (j_metadata.is_null()) |
341 return; | 339 return; |
342 | 340 |
343 ScopedJavaLocalRef<jclass> metadata_class( | 341 ScopedJavaLocalRef<jclass> metadata_class( |
344 GetClass(env, "android/media/Metadata")); | 342 GetClass(env, "android/media/Metadata")); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 | 384 |
387 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { | 385 bool MediaPlayerBridge::RegisterMediaPlayerBridge(JNIEnv* env) { |
388 bool ret = RegisterNativesImpl(env); | 386 bool ret = RegisterNativesImpl(env); |
389 DCHECK(g_MediaPlayerBridge_clazz); | 387 DCHECK(g_MediaPlayerBridge_clazz); |
390 if (ret) | 388 if (ret) |
391 ret = JNI_MediaPlayer::RegisterNativesImpl(env); | 389 ret = JNI_MediaPlayer::RegisterNativesImpl(env); |
392 return ret; | 390 return ret; |
393 } | 391 } |
394 | 392 |
395 } // namespace media | 393 } // namespace media |
OLD | NEW |