I have the following code
val filePath = context.filesDir.path.toString() + "/hello_world.mp3"
val inputStream = WaveUtils.reWriteWaveHeader(response.result)
val size = File(filePath).outputStream().use { inputStream.copyTo(it) }
val file = File (filePath)
Log.i("AMIRA00000" , "size : " + size)
Log.i("AMIRA00000" , "filePath : " + filePath)
val player = MediaPlayer()
player.setDataSource(context , Uri.parse(file.path))
player.prepare()
player.start()
the file size has value and the filePath is as following
/data/user/0/com.sbs16.ensofia/files/hello_world.mp3
which means that the file saved correctly, but the player does not work and give this error
java.io.IOException: Prepare failed.: status=0x1
can anyone please help ?