I\'m trying to use ExoPlayer instead of MediaPlayer because it\'s a common bug that MediaPlayer returns wrong getCurrentPosition() and I need a substitute.
But I can\'t
Using ExoPlayer 2.1, and starting with the demo
project, you can play mp3 files from the assets
folder without modifying any Java code, just by adding the mp3 files in the assets
folder and creating or modifying a json
file. Starting with the ExoPlayer demo
project:
Put the mp3 files in the demo/assets
folder (with media.exolist.json
).
Either modify media.exolist.json
or create a new file such as my.exolist.json
containing one or more entries formatted like this:
{
"name": "Children's Songs",
"samples": [
{
"name": "Mary Had a Little Lamb",
"uri": "asset:///mary1.mp3"
},
{
"name": "Itsy Bitsy Spider",
"uri": "asset:///spider1.mp3"
}
]
},
(The final comma assumes there will be another category following, such as Blues Songs
, Jazz Songs
etc. with more mp3 entries. The final category has no comma after it.)
The figure below shows the chooser activity screen after you click on Children's Songs
:
Click Mary Had a Little Lamb
or Itsy Bitsy Spider
and that mp3 plays.