English 中文(简体)
在其完成之前,媒体角色不健全
原标题:Mediaplayer not playing sound before it finished

我有一顿,每当被点击时,就应当做到正确。 问题在于,它只有在我等到第一次清白之后才能发挥作用。 不管 but子被多次点击的速度如何,我需要这样做。 我使用的卷宗是.mp3,位于我的陈列室项目res aw

I initialized it as:

MediaPlayer player = MediaPlayer.create(activity, R.raw.sound);

我最初的纽子点击代码不过是

player.start();

有能力履行以下职能,但也有同样的问题:

if (player.isPlaying()) {
    player.stop();
}
player.start();
if (player.isPlaying()) {
    player.pause();
    player.restart();
}
player.start();
if (player.isPlaying()) {
    player.restart();
}
player.start();

利用player.prepare()player.prepareAsync( causes java.lang.IllegalStateException 差错,可能是因为我使用的初始化已经称作prepare()。

在职能援引时如何立即做到正确? 不使用<条码>MediaPlayer。 感谢任何帮助。

问题回答

你们还必须在阻止参与者之后释放:

...
player.stop();
player.release();
...




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签