>从每个ListvIEw项目单击一个按钮.
问题:音频正在播放列表视图,但仍然Seekbar没有移动(更新).
编辑:1
1.Audio正在播放每个ListvIEw项目完全,但Seekbar不工作(不更新).
请帮我解决这个问题.
我的ListvIEw数组适配器类:
Adapter.class
@H_301_15@private static final int UPDATE_FREQUENCY = 500; int progress=0; public VIEw getVIEw(final int position,VIEw vIEw,VIEwGroup parent) { LayoutInflater inflater = context.getLayoutInflater(); VIEw rowVIEw = inflater.inflate(R.layout.audio_ListvIEw,null,true); ListenAUdiobutton = (button) rowVIEw.findVIEwByID(R.ID.ListenAudiobuttonxml); seek_bar_vIEw = (Seekbar) rowVIEw.findVIEwByID(R.ID.seek_bar); ListenAUdiobutton.setonClickListener(new VIEw.OnClickListener() { public voID onClick(VIEw v) { // text_shown.setText("Playing..."); try { try { // get Internet status isInternetPresent = cd1.isConnectingToInternet(); // check for Internet status if (isInternetPresent) { if (!itemname3_AUdio_file[position].equals("") || !itemname3_AUdio_file[position].equals("null")) { System.out.println(" AUdio file :-)" + itemname3_AUdio_file[position]); player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(context,Uri.parse(itemname3_AUdio_file[position])); player.prepareAsync(); player.setonPreparedListener(new MediaPlayer.OnPreparedListener() { @OverrIDe public voID onPrepared(MediaPlayer mp) { try { mp.start(); seek_bar_vIEw.setMax(player.getDuration()); updateposition(); } catch (Exception e) { e.printstacktrace(); } } }); player.setonCompletionListener(new MediaPlayer.OnCompletionListener() { @OverrIDe public voID onCompletion(MediaPlayer mp) { stopPlay(); } }); MediaPlayer.OnErrorListener onError = new MediaPlayer.OnErrorListener() { @OverrIDe public boolean onError(MediaPlayer mp,int what,int extra) { // returning false will call the OnCompletionListener return false; } }; } else { Toast.makeText(getContext(),"Audio Not Found..!",Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getContext(),"Please Check Your Internet Connection..!",Toast.LENGTH_SHORT).show(); } } catch (Exception e) { e.printstacktrace(); Toast.makeText(getContext(),Toast.LENGTH_SHORT).show(); } } catch (Exception e) { e.printstacktrace(); } } }); return rowVIEw; } private voID stopPlay() { player.stop(); player.reset(); // playbutton.setimageResource(androID.R.drawable.ic_media_play); handler.removeCallbacks(updatepositionRunnable); seek_bar_vIEw.setProgress(0); // isstarted = false; } private final Handler handler = new Handler(); private final Runnable updatepositionRunnable = new Runnable() { public voID run() { updateposition(); } };private voID updateposition() { handler.removeCallbacks(updatepositionRunnable); seek_bar_vIEw.setProgress(progress);progress=getProgresspercentage(player.getCurrentposition(),player.getDuration(); notifyDataSetChanged(); handler.postDelayed(updatepositionRunnable,UPDATE_FREQUENCY); }解决方法 你需要在每一秒更新你的seekbar位置(值)..设置seekbar最大值..
@H_301_15@seek_bar_vIEw.setMax((int) player.getDuration());并每秒更新一次以显示进度
@H_301_15@Handler mHandler = new Handler(); runOnUiThread(new Runnable() { @OverrIDe public voID run() { seek_bar_vIEw.setProgress((int) player.getCurrentposition()); } mHandler.postDelayed(this,1000); } ); 总结以上是内存溢出为你收集整理的从URI里面的音频播放Listview,但Seekbar在Android Listview项目中没有更新全部内容,希望文章能够帮你解决从URI里面的音频播放Listview,但Seekbar在Android Listview项目中没有更新所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)