[96417]不支持wma格式的歌曲播放
根据经验,直接定位代码,frameworks/base/media/java/android/media/MediaFile.java
果然有跟文件类型相关的,搜wma,发现
if(isWMAEnabled()){ addFileType("WMA",FILE_TYPE_WMA,"audio/x-ms-wma"); }
OK,开始狂跟代码:
isWMAEnabled() -> DecoderCapabilities.getAudioDecoders() -> native_get_audio_decoder_type //这里需要返回数据
找到:android_media_MediaProfiles.cpp
android_media_MediaProfiles_native_get_audio_decoder_type
sProfiles->getAudioDecoders()
decoders.add(mAudioDecoders[i]->mCodec); //发现mCodec 就是audio_decoder
狂搜mAudioDecoders,找出哪里给mAudioDecoders加内容。
。。。Jump to Caller。。。。。
顺读代码:
frameworks/base/media/jni/android_media_MediaProfiles.cpp
android_media_MediaProfiles_native_init() -> sProfiles = MediaProfiles::getInstance();
frameworks/base/media/libmedia/MediaProfiles.cpp
getInstance() ->取在media.settings.xml中设置的配置文件路径给value
如果没有,则以是否存在文件defaultXmlFile = "/etc/media_profiles.xml"决定调用 createDefaultInstance(defaultXmlFile)还是createInstacneFromXmlFile()
如果有,就调用createDefaultInstaces(value);
在两个createDefaultInstance函数中可以判定,media.settings.xml中设置的文件路径有误
狂搜字符串media.settings.xml
-->注释掉isWMAEnabled,单编,发现不行
搜字符串资源:Sorry,the player does not support this type of audio file
packages/apps/Music/res/values/string.xml playback_failed
在 com/android/music/MediaPlaybackService.java 有,
点击播放,LOG:Failed to open file:for playback
packages/apps/Music/src/com/android/music/AudioPreview.java onCreate
MediaPlayerbackService.java
setDataSource(String) -> 只有这里有机会将mIsInitialized设为TRUE
MediaPlayer.java
根据LOG,"content://media/external/audio/media/14
定位setDataSource(Context, Uri) -> setDataSource(Context, Uri, Map<String, String>)
setDataSource(Context,Uri,Map<String,String>) 查看LOG,定位这个参数的函数-
Log.d(TAG,"Couldn't openfile on client side, trying server side");
native void setDataSource(String, Map<String,String>)
android_media_MediaPlayer.cpp 根据参数,定位函数
android_media_MediaPlayer_setDataSourceAndHeaders
mp->setDataSource(const char*, const KeyedVector<String8, String8>*)
Mediaplayer.cpp
setDataSource(const char*, const KeyedVector<String8, String8>*)
--LOGV("setDataSource(%s"),url) 根据LOG,定位此函数
--IMediaDeathNotifier.cpp
--getMediaPlayerService() -> LOGV("getMediaPlayerService")
--MediaPlayerService.cpp
--setDataSource(const char *, const KeyedVector<String8, String8>*)
--LOGV("setDataSource(%s)",url)
android:openContentProviderFile http://www.oschina.net/code/explore/android-4.0.1/core/jni/ActivityManager.cpp
--LOGE("Couldn't open fd for %s", url);
Mediaplayer.cpp
setDataSource(const sp<IMediaPlayer>&) ->LOGE("Unable to to create media player");
MediaPlaybackService.java
Log.d(LOGTAG, "Failed to open file for playback");
其它参考:http://blog.csdn.net/eustoma/article/details/6706322
http://www.oschina.net/code/explore/android-4.0.1/core/jni/ActivityManager.cpp
[96416]进入音乐不可以将歌曲添加到当前的播放列表