0

I record MPEG 4 audio in my android app and upload the file to my web server. I have tried both mp4 and m4a file extensions, but I have not been able to find a way to embed the audio files into a web page. Is there an easy way to do this or would I be better using a different audio format?

Edit 05/04/2014 11:09

Thanks for the replies. My app is a Note Taking app which allows me to record voice notes on my Android phone. This is the code I use for recording the notes:

final MediaRecorder mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mFileName =  sdcard + savename + ".mp4";
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
    mRecorder.prepare();
} catch (IOException e) {
    Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle("Voice Recorder");
alertDialogBuilder
.setMessage("Click stop to save.")
.setCancelable(false)
.setPositiveButton("Stop",
    new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {                          mRecorder.stop();                        
               mRecorder.release();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();

This works fine on the Android phone, the audio file is saved to my sdcard and I can play it back from the phone. I can also change the line "mFileName = sdcard + savename + ".mp4";" to "mFileName = sdcard + savename + ".m4a";" and the audio still plays fine on the phone.

However, when I upload the mp4 or m4a audio file to my web server and try to embed it into a web page, I can't find a way to play the audio. In Chrome by linking to the file Quicktime is opened and it can be played from there, but this does not work in Internet Explorer, and I would rather embed the sound in the web page than launch another application anyway.

Thank You for any help anyone can provide.

Stuart McLaren
  • 119
  • 2
  • 8
  • What extension is it before you change it? --- http://developer.android.com/guide/appendix/media-formats.html --- if its (3gp) you will need to convert the videos to MP4 and then they will play in a HTML5 document--- http://stackoverflow.com/questions/13220019/how-to-play-3gp-video-in-html5 ---- http://www.w3schools.com/html/html5_video.asp – Tasos Apr 04 '14 at 17:18

1 Answers1

0

in my work with SoundJS I've found that mp4 is supported on Android. Often on mobile devices sound playback needs to be kicked off inside of a user initiated event (touch). The Mobile Safe Tutorial might be useful if you want to learn more.

Hope that helps.

OJay
  • 1,249
  • 7
  • 14