Reputation: 3403
I need to set the pitch of a song being played in a media player.I know that the Sound Pool helps to set the pitch but I use the MediaPlayer(since I need Reverb effects too) for playing tracks and I need to set the pitch of the track being played now.Any one have any clue?
Upvotes: 2
Views: 3661
Reputation: 9061
Android 6.0 adds PlaybackParams
for MediaPlayer
. I just tested this in an emulator:
String recordingPath = recordingDirectory + File.separator + "music.mp3";
MediaPlayer audioPlayer = MediaPlayer.create(getApplicationContext(), Uri.parse(recordingPath));
audioPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
PlaybackParams params = new PlaybackParams();
params.setPitch(0.75f);
audioPlayer.setPlaybackParams(params);
audioPlayer.start();
Upvotes: 11