Я создал приложение, связанное с медиаплеером, в котором у меня возникла проблема с BufferUpdate. Вот мой код.
Мой файл seek_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:id="@android:id/background">
<shape>
<gradient
android:endColor="@color/grey_color"
android:startColor="@color/grey_color" />
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:endColor="@color/green_color"
android:startColor="@color/green_color" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:endColor="@color/red_color"
android:startColor="@color/red_color" />
</shape>
</clip>
</item>
Это мой MainActivity.java
private void BufferListener() {
if (mMediaPlayer != null)
{
mMediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
seekBar.setSecondaryProgress(percent);
Toast.makeText(MusicsActivity.this, "Buffer Update "+percent, Toast.LENGTH_SHORT).show();
}
});
}
}
файл main_activity.xml
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="6dp"
android:thumb="@drawable/seek_bar_thumb"
android:progressDrawable="@drawable/seek_bar"/>
Обновление буфера Toast обновляет мне идеальный процент от 1 до 100, но seekBar.setSecondaryProgress(percent);
ничего не обновляет.
как я могу решить эту проблему? Пожалуйста, помогите мне кто-нибудь здесь, спасибо.