Resources$NotFoundException

All your problems with Audio, Video and Images.

Resources$NotFoundException

Postby lord_ure » Fri Apr 16, 2010 4:42 pm

HI everybody, I've tried the tutorial from plusminus on how to play a music. But it doesn't work, I have a resources$NotFoundException about my mp3 file. I don't why. Here is my code :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.me.quizzsound;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.media.MediaPlayer;
  8.  
  9. import android.media.MediaPlayer.OnCompletionListener;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.view.View;
  14.  
  15. import android.view.View.OnClickListener;
  16.  
  17. import android.widget.Button;
  18.  
  19. import java.io.IOException;
  20.  
  21. import java.util.logging.Level;
  22.  
  23. import java.util.logging.Logger;
  24.  
  25.  
  26.  
  27. public class MusicPlayer extends Activity {
  28.  
  29.  
  30.  
  31.     /** Called when the activity is first created. */
  32.  
  33.     @Override
  34.  
  35.     public void onCreate(Bundle icicle) {
  36.  
  37.         super.onCreate(icicle);
  38.  
  39.         setContentView(R.layout.quizzsound);
  40.  
  41.  
  42.  
  43.         // Find the Button from the xml-file.
  44.  
  45.         Button cmd_play = (Button) this.findViewById(R.id.cmd_play);
  46.  
  47.         cmd_play.setOnClickListener(new OnClickListener() {
  48.  
  49.  
  50.  
  51.             @Override
  52.  
  53.             public void onClick(View arg0) {
  54.  
  55.                 MediaPlayer mp = null;
  56.  
  57.                 try {
  58.  
  59.                     mp = MediaPlayer.create(MusicPlayer.this,
  60.  
  61.                             R.raw.assassodomie);
  62.  
  63.                 } catch (Exception e) {
  64.  
  65.                     int g = 0;
  66.  
  67.                 }
  68.  
  69.                 try {
  70.  
  71.                     mp.prepare();
  72.  
  73.                 } catch (IOException ex) {
  74.  
  75.                     Logger.getLogger(MusicPlayer.class.getName()).log(Level.SEVERE, null, ex);
  76.  
  77.                 } catch (IllegalStateException ex) {
  78.  
  79.                     Logger.getLogger(MusicPlayer.class.getName()).log(Level.SEVERE, null, ex);
  80.  
  81.                 }
  82.  
  83.                 mp.start();
  84.  
  85.                 // i.e. react on the end of the music-file:
  86.  
  87.                 mp.setOnCompletionListener(new OnCompletionListener() {
  88.  
  89.  
  90.  
  91.                     // @Override
  92.  
  93.                     public void onCompletion(MediaPlayer arg0) {
  94.  
  95.                         // File has ended !!! Wink
  96.  
  97.                     }
  98.  
  99.                 });
  100.  
  101.             }
  102.  
  103.         });
  104.  
  105.     }
  106.  
  107. }
  108.  
  109.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4


The problem is when create is called and the raw resources called too. My file is in the project and the R.raw.assassodomie variable exists in R.java.
So I have a resources$notfoundexception => FileNotFoundException : "File res/raw/assassodomie.mp3 from drawable resource ID #0x7f030000".

Is it normal the "from DRAWABLE resource" ??

Bye.
PS : Sorry about the language but I'm french. XD

Bye.
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Top

Postby lord_ure » Sat Apr 17, 2010 3:15 pm

I have found another specification : In my exception I have this message "This file can not be opened as a file descriptor; it is probably compressed" It's strange because android knows the mp3 format no?????


regards.
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Postby lord_ure » Mon Apr 19, 2010 12:44 pm

Nobody knows how to solve my problem???????
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Re: Resources$NotFoundException

Postby KOMOKHEPBOB » Mon Jan 31, 2011 1:53 pm

Hi,

Have you found a solution for this problem?
KOMOKHEPBOB
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 31, 2011 1:51 pm

Re: Resources$NotFoundException

Postby lord_ure » Mon Jan 31, 2011 2:05 pm

Hi, I havn't found the problem. I just created an other project and now it works. :shock:
So I don't know what was wrong the first time.

++ 8)
Sorry for my english, I'm french ........ :(
lord_ure
Developer
Developer
 
Posts: 46
Joined: Fri Apr 16, 2010 4:29 pm
Location: Nancy, FRANCE

Top

Return to Multimedia Problems

Who is online

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