calling the MediaPlayer::prepare method in libmedia.so failed

216 views
Skip to first unread message

_pop7

unread,
Aug 28, 2010, 3:05:15 AM8/28/10
to android-ndk
hi, nobody but you :)

i just wanna build a executable which can play music in a android
emulator of froyo by direct calling the function in libmedia.so, my
code is below:
============================================================
sp<MediaPlayer> mplay = new MediaPlayer();
status_t set_ret = mplay->reset();
LOGE("playing reset return %d", set_ret);
set_ret = mplay->setDataSource("/mnt/sdcard/sky.mp3", NULL);
LOGE("playing set data source return %d", set_ret);
set_ret = mplay->prepare();
LOGE("playing prepare return %d", set_ret);
set_ret = mplay->start();
LOGE("playing start return %d", set_ret);
-------------------------------------------------------------------------------------------------------------------------
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := nativemedia.cpp
LOCAL_C_INCLUDES += \
/cygdrive/d/myandroid/frameworks/base/include \
/cygdrive/d/myandroid/system/core/include \
/cygdrive/d/myandroid/bionic
LOCAL_LDLIBS += -llog -lmedia
LOCAL_MODULE := nativemedia
include $(BUILD_EXECUTABLE)

=============================================================
after successful build the nativemedia, i adb push it to the emulator
and run. checking the logcat, we can see the
the two message printed by nativemedia: playing reset return 0;
playing set data source return 0; which indicated
the nativemedia successful called the method reset and setDataSource
in the libmedia.so. however, then the nativemedia stucked in calling
the method prepare in libmedia.so, which just can't continue and
waiting here do nothing.

thanks

David Turner

unread,
Aug 29, 2010, 10:32:34 AM8/29/10
to andro...@googlegroups.com
You can't do that reliably. libmedia.so is a non-public internal system library. Its interface changes all the time between platform releases, and OEM are also free to modify it at will.

You also seem to depend on many internal type declarations, these are all very volatile as well.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Reply all
Reply to author
Forward
0 new messages