0

I am working with Soundcloud API to get the group members' information. Now there are thousands of members in a group. I need to get this done in a "Batch Process" and have to show a progress bar. How can I do this? Any technical solution, please?

Edit: The class should keep in mind about the "server load". I mean to say, server shouldn't be very busy to process this and the CPU load shouldn't get high.

3
  • 2
    How can you do what? Read soundcloud, or show a progress bar? For the latter, see this question: stackoverflow.com/questions/18566362/… Commented May 17, 2014 at 21:11
  • Can you explain what you mean by "Server load"? Commented May 17, 2014 at 21:32
  • @GolezTrol, I have edited my question. Please check. Commented May 18, 2014 at 5:11

1 Answer 1

0

For the progress bar part, the question I mentioned in my comment doesn't seem to provide a proper answer. With some further googling and experimenting I came to this solution, which seems to work in both Chrome and IE11.

<?php 
  set_time_limit(0); // Don't timeout.
  header( 'Content-type: text/html; charset=utf-8' ); 
?><!doctype html>
<html>
<body>
<progress id="progress" max="10" value="1">
</progress>
<div id="test">
Hello world
</div>

<?php
// Apparently this is needed to disable buffering.
ob_implicit_flush(true);
ob_end_flush();

$colors = array('red', 'green', 'blue', 'yellow', 'red', 'green', 'black', 'white', 'blue', 'green', 'pink');
for ($i = 1; $i <= 10; ++$i)
{
  // Outputting a large chunk of data is also mentioned as a work-around, but for me it didn't work.
  // echo str_repeat(' ', 10000);

  // Instead of sleeping, this is where your actual processing would go.
  sleep(1);

  // Echo a small Javascript to update the status.
  ?>
    <script>
    document.getElementById('progress').value = <?=$i?>;
    document.getElementById('test').style.backgroundColor = '<?=$colors[$i]?>';
    document.getElementById('test').innerText = '<?=$i*10?>% done';
    </script>
  <?php
  // The script is flushed right away, and the browser should execute it right away.
  flush();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.