2012-01-19 4 views
0

mでスレッドとsongprgressハンドラの次のサンプルコードの再生と残り時間でアンドロイドシークバーを使用しています。次回/前の曲をクリックするたびに大きな整数値を表示します。この問題を解決するには?シークバーの再生時間と残り時間が大きい整数値を示していますか?

class SongProgressUpdateThread extends Thread { 
    public void run() { 

     if (mp != null) { 
      int currentPosition = 0; 
      int total = mp.getDuration(); 
      while (currentPosition < total && mp.isPlaying() && stopSongProgressThread==false) { 
       try { 
        Thread.sleep(500); 
        currentPosition = mp.getCurrentPosition(); 
       } catch (InterruptedException e) { 
        return; 
       } catch (Exception e) { 
        return; 
       } 
       songProgress.setProgress(currentPosition); 
       showProgress(currentPosition, total); 
      } 

     } 
    } 
} 





private void showProgress(int currentPosition, int duration) { 
    Bundle bundle = new Bundle(); 
    bundle.putString("playedTime", getPlayedTime(currentPosition)); 
    bundle.putString("remainingTime",getRemainigTime(currentPosition, duration)); 
    Message msg = new Message(); 
    msg.setData(bundle); 
    songProgresshandler.sendMessage(msg); 
} 

Handler songProgresshandler = new Handler() { 
    public void handleMessage(Message message) { 
     final Bundle b = message.getData(); 
     playedTime.setText(b.getString("playedTime")); 
     remainingTime.setText("-" + b.getString("remainingTime")); 
    } 
}; 
+0

getPlayedTime()とgetRemainingTimeの実装を貼り付けてください。 – jeet

+0

[行をコードとしてフォーマット](http://meta.stackexchange.com/questions/22186/)に4つのスペースをインデントすることで注意してください。エディタツールバーの "{}"ボタンはこれを行います。あなたの質問を編集して試してみてください。書式設定の詳細とヒントについては、エディタツールバーのオレンジ色の疑問符をクリックしてください。 – outis

+0

質問を要求されたコードで更新してください。一般的に、コメントで返信するのではなく、あなたの投稿を更新することによって、明確化の要求に応えます。一つのこととして、コメントを読まなければ問題は理解できるはずです。別の例として、SOはQAとサイトであり、フォーラムではなく、コメントは意図されていない(またそれに適していない)。 – outis

答えて

0

おそらく、VideoViewとMediaControllerを使ってそれを行うことができます。

VideoView vv = (VideoView)this.findViewById(R.id.videoview); 
Uri uri = Uri.parse(path); 
MediaController mediaController = new MediaController(this); 
mediaController.setMediaPlayer(vv); 
vv.setVideoURI(uri); 
vv.setMediaController(mediaController); 
vv.start(); 
mediaController.show(); 
0

[次へ/前のボタン をクリックしたときに多分メディアプレーヤはそれでLogCatに任意のエラーメッセージを見て、無効な状態の下で(のような「getDuration()無効stautsに」何をした?のような )

関連する問題