AudioTrack Seek in Android -


Can anyone help me how to play audio songs in a specific situation like the intermediate player, because my audiotrack otterrack Mediaplayer No

Is there any way to look for the song to use the audio trach please tell me? Thank you - you can see your work playing the ottatrack works but I can not find it.

  Public Zero Play Direct () {int i = 0; InputStream = getResources (). OpenRawResource (R.raw.output); Int buffer size = audiotrack GetminBuffer Size (44100, Audio Format .CHANNEL_OUT_STEREO, AudioFormat.ACCOIDIPID 6_16 BIT); Logs. V ("buffer size", "" + buffer size); Audiotrack = new audiotrack (audio manager. STREAM_MUSIC, 44100, audio format .CHANNEL_OUT_STEREO, audio format. NCODIDIDI 666, buffer size, audiotrack .MODE_STREAM); Byte [] music = new byte [512]; Try AudioTrack.play (); AudioTrack.setPlaybackPositionUpdateListener (this); While ((i = Reid (music))! = -1) {audioTrack.write (music, 0, I); Logs. V ("audiotrack", "audiotrack =" + ((audiotrack .getPlaybackHeadPosition) / audioTrack.getSampleRate ()) * 1000.0); // log V ("Audiotrack", "Audiotrack =" + Audiotrack.SetLoopPoint (500, 2000, 6)); } Audiotrack.stop (); AudioTrack.release (); } Hold (IOException e) {e.printStackTrace (); }}  

You can not go with audiotrack because you are just feeding samples For this, do not know anything about audiotrak file or timing.

What you can do, in the InputStream file, position the situation in the correct position. Since you have audio stereo, 16 bit and 44100hz, this means that each second of the audio

  bytesPerSecond = 44100 * 2 * 2; // 44100 samples, 2 channels, 2 bytes per sample  

So if you want to seek 5 seconds for example, you will do this

  Seekposition = 5 * bytespersecond;  

Comments