Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling seekbar while sending a file to server in android?
    text
    copied!<p>My purpose is to send an audio file to the server and also update the seekbar control while playing the file.But now the problem is the seekbar is moving only after the sending the file. Can any one suggest a method to solve this issue?</p> <p>My code:</p> <pre><code>private void startPlay(String file) { Log.i("Selected: ", file); selelctedFile.setText(file); seekbar.setProgress(0); player.stop(); player.reset(); try { player.setDataSource(file); player.prepare(); player.start(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } seekbar.setMax(player.getDuration()); playButton.setImageResource(android.R.drawable.ic_media_pause); updatePosition(); isStarted = true; UploadAudio upAudio; try { upAudio = new UploadAudio(new Socket("172.16.2.54", 2000)); upAudio.sendFile(new File(currentFile));//sending file function } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void stopPlay() { player.stop(); player.reset(); playButton.setImageResource(android.R.drawable.ic_media_play); handler.removeCallbacks(updatePositionRunnable); seekbar.setProgress(0); isStarted = false; } </code></pre> <p>private void updatePosition() { handler.removeCallbacks(updatePositionRunnable);</p> <pre><code> seekbar.setProgress(player.getCurrentPosition()); handler.postDelayed(updatePositionRunnable, UPDATE_FREQUENCY); } </code></pre> <p>Thanks </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload