Audio Playback Rate in Android - android

So, I know that this has been done with a few Android apps before, but I cannot for the life of me figure out how, since it's not currently possible through the API.
How does one adjust the playback rate of a sound played through MediaPlayer; either with or without adjusting the pitch is fine for now, though the latter is definitely preferred. If someone can point me in the direction of an open source app that I can use as guidance, that would also be fine.
Thanks in advance.

Looks like AudioTrack.setPlaybackRate should do the trick.
Setting it to half the sample rate of
the content will cause the playback to
last twice as long, but will also
result in a negative pitch shift.
Not sure if you can get a AudioTrack from MediaPlayer...

ExoPlayer from version 2.4 has support playback speed adjustment back to Android Jelly Bean (API level 16). I am using it in my app with another very useful feature - seamlessly loop audio.

Related

Android MediaPlayer HLS change on KitKat 4.4.3

Can anyone shed light on the following problem? The android native mediaplayer seems to now use the PTS (Presentation Time Stamp) values in the transport stream to determine playback in the stream, rather than a simple counter. This behavior appeared to start with the 4.4.3 update. The symptoms of this are as follows:
The MediaController displays unhelpful values and no longer is able to be used to skip ahead or move back for streams that do not have PTS reset to zero in the first segment.
The MediaPlayer returns incorrect values for the getCurrentPosition() api call. Instead of starting at zero, it seems to use the PTS value, and ends returning multiple hours after only 1 second of playback, for example.
I am wondering if anyone can explain this behavior, or can reference a "feature" from this release of KitKat. The closest filed bug in Android I found is here. The player is used in a VideoView. The same playlists report expected numbers for getCurrentPosition() in earlier 4.4.2.
Thanks
It sounds like you're running into the same problem that a lot of people are having with HLS native video on 4.4.3 and 4.4.4: https://code.google.com/p/android/issues/detail?id=70877.
I haven't seen the presentation time stamp mentioned yet so it would be very helpful if you could share your findings on the bug ticket.

Change the pitch of the sound but not changing its playback speed unity3d

I am just developing a sample app in unity (as a beginner) so i am stuck at a point, i need to change the sound which is recorded (like in Talking Tom app).
i am done with recording the audio but when i increase the pitch of the sound the speed of the playback is also changed. i need the playback speed is normal only pitch must be changed.
so can anyone help me on this issue.
Thanks in advance
After a bit of researching, I found that what you're trying to do is called "pitch shifting". It involves a lot of math and mucking about with sound packets apparently because changing the pitch of a sound, automatically changes it's playback speed. Getting it back to the speed you want while still keeping the audio at something considered "normal" is no walk in the park.
In any case, since Unity3D uses C#, you might (and I stress the word might) be able to use this open source library to get the sound effect you need. It's based on NAudio (also open source, and C#) so you should theoretically be able to use it, or parts of it in your project.

MediaPlayer stops when changing SystemClock.setCurrentTimeMillis(millis)

So I have an app that plays a video.
And I have a time sync server for setting the datetime of the device. It seems that whenever I call SystemClock.setCurrentTimeMillis(millis) the video stops.
I am using android.media.MediaPlayer.MediaPlayer() object to play the video?
Has anyone else experienced this? I was planning on creating a watchdog thread that just monitors the current duration. But just wanted to know if anyone had come across this already?
Yes, I came across the same situation on some devices. Probably hardware libs use the system time clock in the in decoding or av sync implementation; it happens. Only solution on those devices was to stop/restart the MediaPlayer. But it probably depends on the implementation of the lower levels.

Screen Video Recording FPS

I have searched a lot on google but unfortunately have not found any solution of screen video recording. If you have used the Screencast Video Recorder from google play, you can better understand my question. Can anyone help me out that how to achieve screen video recording programmatically.
AFAIK Screencast records by reading /dev/graphics/fb0, which is slow.
Programmatically the highest performance method is to create a virtual display. Currently only works on Android 4.4. See the screenrecorder.cpp for how to do this:
https://android.googlesource.com/platform/frameworks/av/+/android-4.4_r1/cmds/screenrecord/screenrecord.cpp
For Android 4.1 and above you can use the SurfaceComposerClient (both from native or Java code), although it's fairly broken on 4.3.
Unless you want to write a screen recorder yourself I wouldn't bother and just use one of the off-the-shelf recorders.
for some more detail see this answer.

Is Android's Visualizer class's handling of media volume inconsistent across different devices?

I have made a music visualizer app for Android. While developing on my HTC Legend (running Android 2.2), I noticed that setting the "media volume" of the phone had no effect on the output of the Visalizer class, i.e. I always got the full-volume amplitude data of the playing music, regardless of the volume setting, which was great because that's precisely what I want.
I have recently purchased an Asus EEE transformer tablet, running Android 3.2, and now the user-set volume DOES impact the volume of the data I get back from the Visualiser class.
Does anyone know what the official behaviour should be? I'd hope for volume independence, but the evidence I've seen points to inconsistent behaviour across different devices...
Is this a driver issue, or has the behaviour changed in 3.2?
Thanks!
Nils
Refere this link here. I think that you are not enable equalizer and visualizer for same seesion id.Accroding to me Audio effects need equalizer engine enable for audio modifications settings.Otherwise it gives higher values and it will be affected by media volume also.

Categories

Resources