455

Playing Audio files from SD card

Question:

I wanted to load files from the SD card into a SoundPool as well as ringtones. I am able to successfully get the path of the files, and I am able to play them with MediaPlayer. However, I need the functionality of the SoundPool. I have tried SoundPool.load(String, int) but it appears to not load the file. Is it possible to load files from the SD card into a SoundPool, or is there a better way to do this?

Answer1:

You can use android.os.Environment.getExternalStorageDirectory() to get the directory to your sdcard and append the file and extension, you can then use SoundPool withload(String path, int priority), to access your file.

Or while not recommended you can even hardcode your path to "/sdcard/".

If the problem is not with getting the soundfile path then you can take a look at <a href="http://www.droidnova.com/creating-sound-effects-in-android-part-1,570.html" rel="nofollow">Creating Sound Effects in Android</a>

Recommend

  • WMV file in an ASP.NET page
  • playing video in iOS 5
  • Android: playing audio files in /res/raw by file name
  • media player does not work in my code
  • What is the difference between a “service account” and an “installed application”?
  • Clear fused location provider's location for testing
  • How to autopopulate a field in SugarCRM form
  • as3-flash: any way to access all the instances placed in different frames from document class?
  • Differences in dis-assembled C code of GCC and Borland?
  • How to use carriage return with multiple line?
  • Limiting recursion to certain level - Duplicate rows
  • Cancel a live stream “fast motion” catch-up in Flash
  • Checking free space on FTP server
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Get one-time binding to work for ng-if
  • QLineEdit password safety
  • Is there any way to access browser form field suggestions from JavaScript?
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Release, debug version and Authorization Google?
  • Adding custom controls to a full screen movie
  • Rearranging Cells in UITableView Bug & Saving Changes
  • AT Commands to Send SMS not working in Windows 8.1
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • coudnt use logback because of log4j
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • apache spark aggregate function using min value
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • java string with new operator and a literal