问题描述
importandroid.app.Activity;importandroid.media.MediaPlayer;importandroid.os.Bundle;importandroid.os.Handler;importandroid.view.MotionEvent;importandroid.view.View;importandroid.webkit.WebView;importandroid.widget.Button;importandroid.widget.SeekBar;importandroid.view.View.*;importandroid.view.View.OnTouchListener;publicclassDua1_ActivityextendsActivity{privateButtonPauseBtn;privateButtonPlayBtn;privateStringdua;privatefinalHandlerhandler=newHandler();privateMediaPlayermp;privateSeekBarseekBar;protectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.dua1);this.PlayBtn=((Button)findViewById(R.id.playImg));this.PauseBtn=((Button)findViewById(R.id.pouseImg));this.seekBar=((SeekBar)findViewById(R.id.seekBar1));this.PlayBtn.setVisibility(0);this.PauseBtn.setVisibility(4);initViews();this.dua=getIntent().getExtras().getString("Dua");WebViewlocalWebView=(WebView)findViewById(R.id.Web_Dua1);localWebView.setBackgroundColor(0);localWebView.loadUrl("file:///android_asset/"+this.dua+".html");localWebView.getSettings().setJavaScriptEnabled(true);localWebView.getSettings().setSaveFormData(true);localWebView.getSettings().setBuiltInZoomControls(true);}privatevoidinitViews(){this.dua=getIntent().getExtras().getString("Dua");inti=getResources().getIdentifier(this.dua,"raw",getPackageName());this.mp=MediaPlayer.create(getApplicationContext(),i);this.seekBar.setMax(this.mp.getDuration());}publicvoidstartPlayProgressUpdater(){seekBar.setProgress(mp.getCurrentPosition());if(mp.isPlaying()){Runnablenotification=newRunnable(){publicvoidrun(){startPlayProgressUpdater();}};handler.postDelayed(notification,1000);mp.pause();PauseBtn.setVisibility(4);PlayBtn.setVisibility(0);seekBar.setProgress(mp.getCurrentPosition());}}privatevoidbuttonClick(){if(!this.mp.isPlaying()){this.PlayBtn.setVisibility(4);this.PauseBtn.setVisibility(0);}try{this.mp.start();startPlayProgressUpdater();return;}catch(IllegalStateExceptione){this.mp.pause();}PauseBtn.setVisibility(4);this.PlayBtn.setVisibility(0);this.mp.pause();}publicvoidonResume(){super.onResume();}protectedvoidonPause(){super.onPause();if((this.mp!=null)&&(this.mp.isPlaying()))this.mp.pause();}protectedvoidonDestroy(){super.onDestroy();if(this.mp==null)return;this.mp.release();this.mp=null;}}
程序能正常运行,但是为什么点击播放按钮,就是播放不了呢!大神们,帮忙看看!