Added methods for controlling playback speed to playback controller
This commit is contained in:
parent
332ed1b883
commit
e65c1b7322
|
@ -1554,6 +1554,16 @@ public class PlaybackService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
public double getCurrentPlaybackSpeed() {
|
||||
if (media.getMediaType() == MediaType.AUDIO && player instanceof AudioPlayer) {
|
||||
AudioPlayer audioPlayer = (AudioPlayer) player;
|
||||
if (audioPlayer.canSetSpeed()) {
|
||||
return audioPlayer.getCurrentSpeedMultiplier();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* call getDuration() on mediaplayer or return INVALID_TIME if player is in
|
||||
* an invalid state. This method should be used instead of calling
|
||||
|
|
|
@ -654,6 +654,24 @@ public abstract class PlaybackController {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean canSetPlaybackSpeed() {
|
||||
return playbackService != null && playbackService.canSetSpeed();
|
||||
}
|
||||
|
||||
public void setPlaybackSpeed(double speed) {
|
||||
if (playbackService != null) {
|
||||
playbackService.setSpeed(speed);
|
||||
}
|
||||
}
|
||||
|
||||
public double getCurrentPlaybackSpeedMultiplier() {
|
||||
if (canSetPlaybackSpeed()) {
|
||||
return playbackService.getCurrentPlaybackSpeed();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if PlaybackController can communicate with the playback
|
||||
* service.
|
||||
|
|
Loading…
Reference in New Issue