minor changes to playback interface
This commit is contained in:
parent
e55d87b684
commit
ab6c3a42ed
5 changed files with 27 additions and 30 deletions
|
|
@ -194,12 +194,6 @@ public class MultiPlayer implements Playback {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
exoPlayer.release();
|
||||
isReady = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pause() {
|
||||
isPlaying = false;
|
||||
|
|
@ -207,14 +201,14 @@ public class MultiPlayer implements Playback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
return isReady && isPlaying;
|
||||
public void stop() {
|
||||
exoPlayer.release();
|
||||
isReady = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int duration() {
|
||||
if (!isReady) return -1;
|
||||
return (int) exoPlayer.getDuration();
|
||||
public boolean isPlaying() {
|
||||
return isReady && isPlaying;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -224,13 +218,18 @@ public class MultiPlayer implements Playback {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int seek(int position) {
|
||||
exoPlayer.seekTo(position);
|
||||
return position;
|
||||
public int duration() {
|
||||
if (!isReady) return -1;
|
||||
return (int) exoPlayer.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVolume(float volume) {
|
||||
public void seek(int position) {
|
||||
exoPlayer.seekTo(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void volume(float volume) {
|
||||
exoPlayer.setVolume(volume);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -887,13 +887,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
|
||||
public int seek(int millis) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
int newPosition = playback.seek(millis);
|
||||
throttledSeekHandler.notifySeek();
|
||||
return newPosition;
|
||||
} catch (Exception e) {
|
||||
return -1;
|
||||
}
|
||||
playback.seek(millis);
|
||||
throttledSeekHandler.notifySeek();
|
||||
return millis;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1064,22 +1060,22 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
switch (msg.what) {
|
||||
case DUCK:
|
||||
if (PreferenceUtil.getInstance(service).getAudioDucking()) {
|
||||
currentDuckVolume -= .05f;
|
||||
if (currentDuckVolume > .2f) {
|
||||
currentDuckVolume -= 0.05f;
|
||||
if (currentDuckVolume > 0.2f) {
|
||||
sendEmptyMessageDelayed(DUCK, 10);
|
||||
} else {
|
||||
currentDuckVolume = .2f;
|
||||
currentDuckVolume = 0.2f;
|
||||
}
|
||||
} else {
|
||||
currentDuckVolume = 1f;
|
||||
}
|
||||
|
||||
service.playback.setVolume(currentDuckVolume);
|
||||
service.playback.volume(currentDuckVolume);
|
||||
break;
|
||||
|
||||
case UNDUCK:
|
||||
if (PreferenceUtil.getInstance(service).getAudioDucking()) {
|
||||
currentDuckVolume += .03f;
|
||||
currentDuckVolume += 0.03f;
|
||||
if (currentDuckVolume < 1f) {
|
||||
sendEmptyMessageDelayed(UNDUCK, 10);
|
||||
} else {
|
||||
|
|
@ -1089,7 +1085,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
|||
currentDuckVolume = 1f;
|
||||
}
|
||||
|
||||
service.playback.setVolume(currentDuckVolume);
|
||||
service.playback.volume(currentDuckVolume);
|
||||
break;
|
||||
|
||||
case TRACK_WENT_TO_NEXT:
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ public interface Playback {
|
|||
|
||||
int duration();
|
||||
|
||||
int seek(int position);
|
||||
void seek(int position);
|
||||
|
||||
void setVolume(float volume);
|
||||
void volume(float volume);
|
||||
|
||||
interface PlaybackCallbacks {
|
||||
void onTrackStarted();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue