问题描述
protected MediaPlayer _mediaPlayer;
protected void playFromResource(int resId)
{
if (_mediaPlayer != null)
{
_mediaPlayer.stop();
_mediaPlayer.release();
}
_mediaPlayer = MediaPlayer.create(this, resId);
_mediaPlayer.start();
}
此代码过去在模拟器和设备上都可以正常工作.一段时间以来(我认为是因为我更新到 ADT r10)它只适用于设备.在模拟器上不再有声音,并且应用程序在传递 on _mediaPlayer.release() 时冻结(第二次调用该函数).我能够通过将 stop() 和 release() 替换为 reset() 来防止应用程序崩溃,但它不能解决主要问题:模拟器没有声音.
This code used to work fine on both the emulator and on devices. Since some time (I think it is since I updated to ADT r10) it only works on devices. On the emulator there is no sound anymore and the application freezes when it pass on _mediaPlayer.release() (the second time the function is called). I was able to keep the application from crashing by replacing the stop() and release() by reset() but it does not solve the main issue: There is no sound on the emulator.
在调用 start()
03-09 19:14:30.716: WARN/AudioTrack(34): 获取缓冲区超时(是CPU 挂钩?) 0x1afb8 user=00001e00, server=00000600
03-09 19:14:30.716: WARN/AudioTrack(34): obtainBuffer timed out (is the CPU pegged?) 0x1afb8 user=00001e00, server=00000600
有什么线索吗???
推荐答案
看来问题只出在我的电脑上.我刚刚在另一台电脑上试了一下,效果很好.我升级到 ADT 的 r10 时遇到了一些问题.也许我的开发设置有问题.
Looks like the issue is only on my computer. I just tryed it on another computer and it work fine. I had some issues when I upgraded to r10 of ADT. Maybe there is something wrong in my development setup.
这篇关于自 r10 以来,MediaPlayer 不再在模拟器上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)