1. Download our Official Android App: Forums for Android!

Trouble with playing audio from file

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

  1. AndroiDev

    AndroiDev Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    8
    Joined:
    Jun 9, 2010

    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 Lurker
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Jul 14, 2010

    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...