![](/img/trans.png)
[英]How to get rid of “media playing” notification shown by Chrome on Android?
[英]Android notification when media file is done playing
我有一个带有所有方法的mediaplayer
类。 我只是想获得何时播放文件的指示,但是遇到了麻烦。 方法如下:
public boolean isPlaying()
{
final boolean still_playing = true;
mediaplayer.setOnCompletionListener(new OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer mp)
{
still_playing = false;
}
});
return still_playing;
}
我遇到错误,例如the final local variable cannot be assigned, since it is defined in an enclosing type
或者当我尝试其他操作时,我得到了variabledeclaratorIdexpected
您的final boolean still_playing = true;
是一个常量变量,表示在运行时无法更改。
在程序的后面:
@Override
public void onCompletion(MediaPlayer mp)
{
still_playing = false;
}
您正在尝试更改其价值。
为了解决这个问题,您应该定义boolean still_playing = true;
作为sow这样的类的成员变量:
public class classExample {
// member variables
private boolean still_playing = true;
public boolean isPlaying() {
/* I DELETED THE VARIABLE AND DECLARED IT OUTSIDE THE METHOD */
mediaplayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
/* You could declare it here too without the private
keyword like this:
boolean still_playing = true; */
still_playing = false;
}
});
return still_playing;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.