Added methods for controlling playback speed to playback controller

This commit is contained in:
daniel oeh 2013-05-02 20:57:10 +02:00
parent 332ed1b883
commit e65c1b7322
2 changed files with 28 additions and 0 deletions

View File

@ -1553,6 +1553,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 * call getDuration() on mediaplayer or return INVALID_TIME if player is in

View File

@ -654,6 +654,24 @@ public abstract class PlaybackController {
return false; 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 * Returns true if PlaybackController can communicate with the playback
* service. * service.