[英]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.