1. Check out our companion app, Forums for Android! Download from Google Play

Trouble with playing audio from file

Discussion in 'Android Apps & Games' started by AndroiDev, Jun 9, 2010.

  1. AndroiDev

    AndroiDev Member
    Thread Starter
    5

    Jun 9, 2010
    8
    0
    5
    Hi folks,

    When the .mp3 file was in the res/raw folder, it played fine but when I tried to play it from another source using :

    final String = " D:\\sample.mp3";
    MediaPlayer mp = new MediaPlayer();
    mp.setDataSource(path);
    mp.prepare();
    mp.start();

    it doesn't play.

    What could be the problem?
     

    Advertisement

  2. Antti

    Antti New Member
    5

    Jul 14, 2010
    3
    0
    5
    Try to change
    final String = " D:\\sample.mp3";
    to
    final String = "/sdcard/sample.mp3";

    That works for me.
     

Share This Page

Loading...