rename some existing methods in the playback interface
This commit is contained in:
parent
569f2240ff
commit
e6ad84f16c
4 changed files with 26 additions and 23 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package com.dkanada.gramophone.helper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class StopWatch {
|
||||
|
|
@ -40,6 +42,7 @@ public class StopWatch {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(Locale.getDefault(), "%d millis", getElapsedTime());
|
||||
|
|
|
|||
|
|
@ -247,24 +247,24 @@ public class MultiPlayer implements Playback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int position() {
|
||||
public int getPosition() {
|
||||
if (!isReady) return -1;
|
||||
return (int) exoPlayer.getCurrentPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int duration() {
|
||||
public int getDuration() {
|
||||
if (!isReady) return -1;
|
||||
return (int) exoPlayer.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seek(int position) {
|
||||
public void setPosition(int position) {
|
||||
exoPlayer.seekTo(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void volume(float volume) {
|
||||
exoPlayer.setVolume(volume);
|
||||
public void setVolume(int volume) {
|
||||
exoPlayer.setVolume(volume / 100f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -886,11 +886,11 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
}
|
||||
|
||||
public int getSongProgressMillis() {
|
||||
return playback.position();
|
||||
return playback.getPosition();
|
||||
}
|
||||
|
||||
public int getSongDurationMillis() {
|
||||
return playback.duration();
|
||||
return playback.getDuration();
|
||||
}
|
||||
|
||||
public long getQueueDurationMillis(int position) {
|
||||
|
|
@ -904,7 +904,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
|
||||
public int seek(int millis) {
|
||||
synchronized (this) {
|
||||
playback.seek(millis);
|
||||
playback.setPosition(millis);
|
||||
throttledSeekHandler.notifySeek();
|
||||
return millis;
|
||||
}
|
||||
|
|
@ -1060,7 +1060,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
private static final class PlaybackHandler extends Handler {
|
||||
@NonNull
|
||||
private final WeakReference<MusicService> mService;
|
||||
private float currentDuckVolume = 1.0f;
|
||||
private int currentDuckVolume = 100;
|
||||
|
||||
public PlaybackHandler(final MusicService service, @NonNull final Looper looper) {
|
||||
super(looper);
|
||||
|
|
@ -1077,32 +1077,32 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
switch (msg.what) {
|
||||
case DUCK:
|
||||
if (PreferenceUtil.getInstance(service).getAudioDucking()) {
|
||||
currentDuckVolume -= 0.05f;
|
||||
if (currentDuckVolume > 0.2f) {
|
||||
currentDuckVolume -= 5;
|
||||
if (currentDuckVolume > 20) {
|
||||
sendEmptyMessageDelayed(DUCK, 10);
|
||||
} else {
|
||||
currentDuckVolume = 0.2f;
|
||||
currentDuckVolume = 20;
|
||||
}
|
||||
} else {
|
||||
currentDuckVolume = 1f;
|
||||
currentDuckVolume = 100;
|
||||
}
|
||||
|
||||
service.playback.volume(currentDuckVolume);
|
||||
service.playback.setVolume(currentDuckVolume);
|
||||
break;
|
||||
|
||||
case UNDUCK:
|
||||
if (PreferenceUtil.getInstance(service).getAudioDucking()) {
|
||||
currentDuckVolume += 0.03f;
|
||||
if (currentDuckVolume < 1f) {
|
||||
currentDuckVolume += 3;
|
||||
if (currentDuckVolume < 100) {
|
||||
sendEmptyMessageDelayed(UNDUCK, 10);
|
||||
} else {
|
||||
currentDuckVolume = 1f;
|
||||
currentDuckVolume = 100;
|
||||
}
|
||||
} else {
|
||||
currentDuckVolume = 1f;
|
||||
currentDuckVolume = 100;
|
||||
}
|
||||
|
||||
service.playback.volume(currentDuckVolume);
|
||||
service.playback.setVolume(currentDuckVolume);
|
||||
break;
|
||||
|
||||
case TRACK_WENT_TO_NEXT:
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ public interface Playback {
|
|||
|
||||
boolean isPlaying();
|
||||
|
||||
int position();
|
||||
int getPosition();
|
||||
|
||||
int duration();
|
||||
int getDuration();
|
||||
|
||||
void seek(int position);
|
||||
void setPosition(int position);
|
||||
|
||||
void volume(float volume);
|
||||
void setVolume(int volume);
|
||||
|
||||
interface PlaybackCallbacks {
|
||||
void onTrackStarted();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue