MediaPlayer 在 AVD 上播放文件,在 PDA 上抛出错误
这是我播放文件的方法,在 AVD 上一切正常,没有错误,当我单击 PDA 上的控件时,我收到这些 LogCat 事件: http://pastebay.com/125483。我不知道发生了什么事。请指教。
public void playAudio (int playAudio) {
player = MediaPlayer.create(this, playAudio);
try {
if (player != null) {
player.stop();
}
player.prepare();
player.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
This is my method in service for playing files, on AVD everything works fine, no errors, when I click the control on PDA I get these LogCat events: http://pastebay.com/125483. I have no clue what is happening. Please advise.
public void playAudio (int playAudio) {
player = MediaPlayer.create(this, playAudio);
try {
if (player != null) {
player.stop();
}
player.prepare();
player.start();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了,问题是我调用了prepare();在 MediaPlayer.create 之后,因为它已经准备好了 MediaPlayer。
I solved it, the problem was I called prepare(); after MediaPlayer.create since it prepares the MediaPlayer already.