MediaPlayer no longer working on the emulator since r10?(自 r10 以来,MediaPlayer 不再在模拟器上工作?)
问题描述
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 不再在模拟器上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自 r10 以来,MediaPlayer 不再在模拟器上工作?
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01