2010-08-23 4 views
4

j'ai trouvé que le code à enregistrer, mais je reçois toujours:Android Audio Record

La méthode setOutputFile (FileDescriptor) dans le MediaRecorder type n'est pas applicable pour les arguments (Uri)

Alors, comment aurais-je besoin pour décrire le chemin de fichier que cela fonctionne? thx

// Prepare recorder source and type 
MediaRecorder recorder = new MediaRecorder(); 
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 

// File to which audio should be recorded 
File outputFile = getFileStreamPath("output.amr"); 
Uri target = Uri.parse(outputFile.getAbsolutePath()); 
recorder.setOutputFile(target); 

// Get ready! 
recorder.prepare(); 

// Start recording 
recorder.start(); 

// Stop and tidy up 
recorder.stop(); 
recorder.release(); 

Répondre

1

Vous essayez de passer dans un Uri comme paramètre à la méthode qui ne prévoit pas que. Il suffit de remplacer recorder.setOutputFile(target) avec:

recorder.setOutputFile(outputFile.getAbsolutePath()); 

Cela devrait fonctionner depuis paramètre de chaîne est autorisée.

+0

thx, c'est tout :) –