在android中播放嵌入html问题的mp3文件

时间:2013-04-24 06:58:11

标签: android

在使用以下代码录制mp3音频并将其嵌入html时,音频无法在浏览器中播放:

                    mRecorder = new MediaRecorder();
                    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                    mRecorder.setOutputFile("filepath");
                    mRecorder.prepare();
                    mRecorder.start();
                    addRecordingToMediaLibrary();


protected void addRecordingToMediaLibrary() {
    ContentValues values = new ContentValues(4);
    long current = System.currentTimeMillis();
    //values.put(MediaStore.Audio.Media.TITLE,audiofile.getName());
    values.put(MediaColumns.DATE_ADDED, (int) (current / 1000));
    values.put(MediaColumns.MIME_TYPE, "audio/3gpp");
    values.put(MediaColumns.DATA, audiofile.getAbsolutePath());
    ContentResolver contentResolver = getContentResolver();

    Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    Uri newUri = contentResolver.insert(base, values);

    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, newUri));

 }

但如果我将其改为

                    mRecorder = new MediaRecorder();
                    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
                    mRecorder.setOutputFile("filepath");
                    mRecorder.prepare();
                    mRecorder.start();
                    addRecordingToMediaLibrary();

声音在浏览器中播放但有很多干扰。

即。用AudioEncoder.AAC

替换MPEG_4和AudioEncoder的outputformat

有谁能建议哪种格式适合在Android中嵌入html?

0 个答案:

没有答案