自 r10 以来,MediaPlayer 不再在模拟器上工作?

MediaPlayer no longer working on the emulator since r10?(自 r10 以来,MediaPlayer 不再在模拟器上工作?)
本文介绍了自 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 不再在模拟器上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)