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
Post a Comment