1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Trouble with playing audio from file


Last Updated:

  1. AndroiDev

    AndroiDev Member This Topic's Starter

    Joined:
    Jun 9, 2010
    Messages:
    8
    Likes Received:
    0
    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

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

    That works for me.
     

Share This Page

Loading...