android - Play mp3 with continues from some mp3, pause and stop? -
i have mp3 files inside android internal folder.
i want add feature continues, play, pause, , stop
code run under still less able work well, there 1 can give solution
play_murotal class
public play_murotal(context context, listview listview, string nama_surat, long id_surat) { this.context = context; this.nama_surat = nama_surat; this.listview = listview; this.id_surat = id_surat; } public mediaplayer play_murotal_ayat() { final string dir_file = context.getfilesdir() + "/" + nama_surat; file root = new file(dir_file); final file[] files = root.listfiles(); // delay time play mp3 handler handler = new handler(); final list<integer> listdurasi = new arraylist<integer>(); (int = 0; < files.length; a++) { final string nama_file = files[a].getname(); // durasi total int durasi = get_duration_murotal(dir_file + "/" + nama_file); listdurasi.add(durasi); int durasitotal = 0; (int b = 0; b < listdurasi.size(); b++) { if (b == 0) { durasitotal = 0; } else { durasitotal += listdurasi.get(b); } } final int finala = a; handler.postdelayed(new runnable() { @requiresapi(api = build.version_codes.kitkat) @override public void run() { listview.setselection(finala - 1); play(dir_file,nama_file); } }, durasitotal); } return mplayer; } public void play(string dir_file, string nama_file){ this.mplayer = mediaplayer.create(context, uri.parse(dir_file + "/" + nama_file)); this.mplayer.start(); } public void pause(){ mplayer.pause(); }
Comments
Post a Comment