Search code examples
androidaudioplaybackslowdown

Android R Id to type File


I'm making an app that must slow down the playback of audio files. The audio files' ids are in an int[] array (like R.raw.one, R.raw.two). Here's my problem, I'm trying to iterate through this array, pick out an id to get the audio file, and put it in a FileInputStream so I can eventually read it to an AudioTrack and slow the audio down. The problem is that FileInputStream only takes File type, not int (the ID is hexadecimal).

I can't think of another way to do this. Can I slow down playback with MediaPlayer? Because that would be way easier.

Thanks


Solution

  • getResources().openRawResource(R.raw.one);
    

    will return an input stream of the file. not that getResources is a context method.