I have an application that records audio and saves it on the server on Parse.
I'm trying to retrieve it to play the recorded audio back.
The server is in between because the app sends the audio from one user to another.
I'm just a bit confused as to how the ParseFile
actually works and what's the best way to play it back.
At the moment I'm querying the object, get it's audio property as a ParseFile
, get the url then stream that from the server.
// result is the object I got from the query, it holds the ParseFile
ParseFile audioFile = result.getAudioFile();
String audioFileURL = audioFile.getUrl();
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setAudioStreamType(android.media.AudioManager.STREAM_MUSIC);
try {
mMediaPlayer.setDataSource(audioFileURL);
mMediaPlayer.prepare();
mMediaPlayer.start();
}catch (Exception e){}
I'm thinking this isn't the best way to do it, and it's probably better to save it locally.
I know you can use getDataInBackground
, but I'm just confused as to what that does to the actual ParseFile
. Once I get the data in the background, as an array of byte, what is the best way to store that so that I don't have to call getDataInBackground
everytime? Should I overwrite the ParseFile with a new one I make from the data I get in getDataInBackground
?
Thanks.