title: Android MediaPlayer - I/O error - File not found
body: <p>I have a res/raw folder made in the project in which I placed a single file t.mp4. I intended to use a textureview to play the video file using the SurfaceTextureAvailable listener by implementing the relevant interface.</p>
  
  <p>I created a mediaplayer object in the onSurfaceTextureAvailable method</p>
  
  <pre><code>public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
          Surface s = new Surface(surface);
          Log.d("debug", "Surface Texture Available");
          mMediaPlayer = new MediaPlayer();
          try {
              mMediaPlayer.setDataSource(this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.t));
              Log.d("debug", "data source set");
              mMediaPlayer.setSurface(s);
              Log.d("debug", "Surface set");
              mMediaPlayer.prepare();
              Log.d("debug", "prepared");
              mMediaPlayer.setOnBufferingUpdateListener(this);
              mMediaPlayer.setOnCompletionListener(this);
              mMediaPlayer.setOnPreparedListener(this);
              mMediaPlayer.setOnVideoSizeChangedListener(this);
              Log.d("debug", "listeners set");
              mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
          } catch (IOException e) {
              e.printStackTrace();
          } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              Log.d("error", e.getMessage());
          } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              Log.d("error", e.getMessage());
          } catch (IllegalStateException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              Log.d("error", e.getMessage());
          }
      }
  </code></pre>
  
  <p>This worked fine the first few times I ran the app, but after working on another (non-related) part of my project, it suddenly stopped working.</p>
  
  <p>In the log, I keep getting an IOException, which I am 90% sure is because the application cannot find the file.</p>
  
  <p>What happened?</p>
  
  <p>Cheers</p>