caching - android - download audio to app cache directory and then play -


in nutshell, have button should either download audiofile direct url private app cache directory, or (if done) play file cache.

how can solve it? provide examples, please?

first of need download file , save path either in preference (recommended if have 1 or couple files) or in database (ideal if lot of files).

here can find cool guide on how download file , save it. have @ this article official docs know better how save file properly.

once save save path file in 1 of ways suggested before , play this:

mediaplayer mp = new mediaplayer(); mp.setdatasource(path); mp.prepare(); mp.start(); 

take this article in docs further information.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -