Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Media player problem whit audio file stored in memory

Media player problem whit audio file stored in memory

All your problems with Audio, Video and Images.

Media player problem whit audio file stored in memory

Postby De curtis » Thu Nov 17, 2011 7:49 pm

hi guys i have this strange problem:
i create a app, in this app i record voice in ogg file, i store file in memory (i see the file using DDMS) , when i wont to play the file audio i have a error
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ublic class Testesempio9Activity extends Activity {
  2.     /** Called when the activity is first created. */
  3.         // per registrare la voce
  4.         MediaRecorder recorder;
  5.         // per ascoltare
  6.          MediaPlayer mediaPlayer;
  7.        
  8.         private final static String RECORDING_FILE_NAME = "/data/data/com.esempio9/record_audio.3gp";
  9.          final String ACTIVITY_TAG="AppRECORD";
  10.        
  11.         @Override
  12.     public void onCreate(Bundle savedInstanceState) {
  13.         super.onCreate(savedInstanceState);
  14.         setContentView(R.layout.main);  
  15.      
  16.         // play rec
  17.   Button playRecBtn= (Button) findViewById(R.id.btnPlay);
  18.        
  19.   playRecBtn.setOnClickListener(new OnClickListener() {
  20.                
  21.                 public void onClick(View arg0) {
  22.                         Log.i(ACTIVITY_TAG, "stop l'intent  ");
  23.                 // se il registratore e' gia' in uso   
  24.                         if(recorder!=null){
  25.                                 // Se esiste ne liberiamo le risorse
  26.                                 recorder.release();
  27.                                 Log.i("ACTIVITY_TAG", "Se esiste ne liberiamo le risorse");
  28.                         }
  29.                        
  30.                         // Se esiste già un file lo cancelliamo
  31.                         File mediaFile = new File(RECORDING_FILE_NAME);
  32.                         if(mediaFile.exists()){
  33.                                 Log.i(ACTIVITY_TAG, "elimino il file già creato");
  34.                                 mediaFile.delete();
  35.                         }
  36.                        
  37.                        
  38.                         // creo il recoder
  39.                         recorder= new MediaRecorder();
  40.                         // impostazioni recorder
  41.                         recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  42.                         recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
  43.                     recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
  44.                     recorder.setOutputFile(RECORDING_FILE_NAME);
  45.                     // Avviamo la registrazione
  46.                     try {
  47.                         Log.i(ACTIVITY_TAG, "creo il file amr_anb con il TRY");
  48.                          recorder.prepare();
  49.                          recorder.start();
  50.                         } catch (Exception e) {
  51.                                 Log.i(ACTIVITY_TAG, "ECCEZIONE REGISTRAZIONE");
  52.                                 e.printStackTrace();
  53.                                                
  54.                         }
  55.                        
  56.                        
  57.                 }
  58.         }
  59.       );      // fine play rec
  60.    
  61.  
  62.   // stop  rec
  63.   Button stopRecBtn= (Button) findViewById(R.id.btnStop);
  64.        
  65.   stopRecBtn.setOnClickListener(new OnClickListener() {
  66.                
  67.                 public void onClick(View arg0) {
  68.                                
  69.                         Log.i(ACTIVITY_TAG, "Stop Recording..");
  70.                         if(recorder!=null){
  71.                                 // Se esiste lo fermiamo
  72.                                 recorder.stop();
  73.                                 recorder.release();
  74.                         }
  75.                        
  76.                 }
  77.         }
  78.       );
  79.      
  80.   // start  player
  81.   Button startPlayBtn= (Button) findViewById(R.id.startPlay);
  82.        
  83.   startPlayBtn.setOnClickListener(new OnClickListener() {
  84.                
  85.                 public void onClick(View arg0) {
  86.                                
  87.                         Log.i(ACTIVITY_TAG, "Start PLAYER..");
  88.                
  89.                         if(mediaPlayer!=null){
  90.                                 mediaPlayer.release();
  91.                         }
  92.                         mediaPlayer = new MediaPlayer();
  93.  
  94.                           try {
  95.                                  
  96.                                 mediaPlayer.reset();
  97.                                         mediaPlayer.setDataSource(RECORDING_FILE_NAME);                                
  98.                                         mediaPlayer.prepare();
  99.                                         mediaPlayer.start();           
  100.                                 } catch (Exception e) {
  101.                                         e.printStackTrace();
  102.                                 //      Log.i(ACTIVITY_TAG, "Stop Recording..");
  103.                                         Log.i(ACTIVITY_TAG, e.getMessage());
  104.                                        
  105.                                 }
  106.                        
  107.                 }
  108.         }
  109.       );
  110.  
  111.   Button stopPlayBtn= (Button) findViewById(R.id.StopPlay);
  112.  
  113.   stopPlayBtn.setOnClickListener(new OnClickListener() {
  114.                
  115.                 public void onClick(View arg0) {
  116.                                
  117.                         if(mediaPlayer!=null){
  118.                                 Log.i(ACTIVITY_TAG, "stop se non e' nullo");
  119.                                         mediaPlayer.stop();
  120.                         }      
  121.        
  122.                 }
  123.         }
  124.       );
  125.      
  126.     }
  127.   }
  128.  
Parsed in 0.020 seconds, using GeSHi 1.0.8.4


i have this error
Code: Select all
1-16 20:26:10.638: INFO/AppRECORD(335): Star PLAYER..
11-16 20:26:10.648: INFO/AppRECORD(335): Parte il playing
11-16 20:26:10.658: INFO/StagefrightPlayer(34): setDataSource('/data/data/com.esempio9/record_audio.3gp')
11-16 20:26:10.667: ERROR/MediaPlayer(335): error (1, -2147483648)
11-16 20:26:10.667: WARN/System.err(335): java.io.IOException: Prepare failed.: status=0x1
11-16 20:26:10.677: WARN/System.err(335):     at android.media.MediaPlayer.prepare(Native Method)
11-16 20:26:10.677: WARN/System.err(335):     at com.esempio9.Testesempio9Activity$3.onClick(Testesempio9Activity.java:117)
11-16 20:26:10.677: WARN/System.err(335):     at android.view.View.performClick(View.java:2485)
11-16 20:26:10.677: WARN/System.err(335):     at android.view.View$PerformClick.run(View.java:9080)
11-16 20:26:10.677: WARN/System.err(335):     at android.os.Handler.handleCallback(Handler.java:587)
11-16 20:26:10.677: WARN/System.err(335):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-16 20:26:10.677: WARN/System.err(335):     at android.os.Looper.loop(Looper.java:123)
11-16 20:26:10.677: WARN/System.err(335):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-16 20:26:10.677: WARN/System.err(335):     at java.lang.reflect.Method.invokeNative(Native Method)
11-16 20:26:10.677: WARN/System.err(335):     at java.lang.reflect.Method.invoke(Method.java:507)
11-16 20:26:10.677: WARN/System.err(335):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-16 20:26:10.677: WARN/System.err(335):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)


i think the problem is in mediaPlayer.setDataSource(RECORDING_FILE_NAME); but I do not know how to fix it
please help me
best regads
Antonio
De curtis
Freshman
Freshman
 
Posts: 4
Joined: Wed Jul 06, 2011 3:50 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 10 guests