android - How do I specify a wav file on my sdcard as a Uri -
i want play wav file on sdcard using mediaplayer class. android developer's website says can play local media uri. code snippet
uri myuri = ....; // initialize uri here mediaplayer mediaplayer = new mediaplayer(); mediaplayer.setaudiostreamtype(audiomanager.stream_music); mediaplayer.setdatasource(getapplicationcontext(), myuri); mediaplayer.prepare(); mediaplayer.start();
how set local file uri?
---edit---
answers
ended using uri myuri = uri.parse(filepath)
have verified answers work.
you try this:
file file = new file("myfile.wav"); uri uri = uri.fromfile(file);
Comments
Post a Comment