2016-11-21 1 views
0

첫 번째 활동에서 만든 녹음을 저장 한 다음 Android App의 두 번째 활동에서 녹음을 재생하고 싶습니다. 나는 모든 것을 가지고 있다고 생각하지만 첫 번째 활동을 저장하고 두 번째 활동에서 액세스 할 수있는 방법을 찾는 것 같습니다.하나의 응용 프로그램에 mp3 녹음을 저장하고 다른 음성 녹음을 재생하는 방법

지금은 파일을 찾을 수 없기 때문에 응용 프로그램이 충돌합니다. 검토를 위해 첫 번째 및 두 번째 활동의 일부를 포함 할 것입니다.

파일 경로가이 파일의 첫 번째 활동에서 다시

private void playSound(boolean speakers) { 
     mContext = getApplicationContext(); 
     mFile = "files" + "/audio_test.3gp"; 
     audioManager.setSpeakerphoneOn(true); 
     try { 
      mp.setDataSource(mFile); 
     } catch (IOException e) { 
      e.printStackTrace(); 
+0

저장 및 파일 경로를 검색하는 것은 동일해야합니다 (또는 더 나은 아직, 오히려 사용 문자열 연결보다 두 장소에서 new File(getFilesDir(), "audio_test.3gp")를 사용). 그것이 다른 두 번째 활동에서 당신을 확인하십시오. –

답변

0

를 연주하는 두 번째 활동에서이다

try{ 
    Log.i(log_tag,"Setting the recorder"); 
    speaker_recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    speaker_recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
    speaker_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
     speaker_recorder.setOutputFile(getFilesDir().getAbsolutePath() + "/audio_test.3gp"); 

    } catch(Exception e){ 
     Log.e(log_tag,"Recording Settings Failed"); 
     createTempFile("Status.txt", "COMPLETED-RECORDER FAILED"); 
    } 
    //Prepare the Recorder 
    try{ 
     Log.i(log_tag,"Preparing the Recorder"); 
     speaker_recorder.prepare(); 
    } catch(Exception e){ 
     Log.e(log_tag,"Recording failed"); 
     createTempFile("Status.txt", "COMPLETED-RECORDER FAILED"); 
     exit_function(); 
    } 

설정되는 첫 번째 활동에서, 당신은이 : 두 번째 활동에서

getFilesDir().getAbsolutePath() + "/audio_test.3gp" 

, 당신은 :

"files" + "/audio_test.3gp"; 

이들은 서로 다릅니다. 또한, 두 번째 것은 올바르지 않습니다. 두 번째 활동을 변경하여 첫 번째 활동에서 사용한 것과 같은 논리를 사용하여 경로를 파생시킵니다.

+0

정말 고마워요 !!! – Toby

관련 문제