/** * Checks to see if a movie is available and returns either a link to the * movie if it is ready or progress information otherwise * * @return void */ public function getMovieStatus() { include_once HV_ROOT_DIR . '/../src/Movie/HelioviewerMovie.php'; require_once HV_ROOT_DIR . '/../lib/Resque.php'; require_once HV_ROOT_DIR . '/../lib/Resque/Job.php'; $queueNum = $this->_getQueueNum(HV_MOVIE_QUEUE, $this->_params['id']) + 1; // Process request $movie = new Movie_HelioviewerMovie($this->_params['id'], $this->_params['format']); $verbose = isset($this->_options['verbose']) ? $this->_options['verbose'] : false; if ($movie->status == 0) { // QUEUED $jobStatus = ''; if (isset($this->_params['token']) && $this->_params['token'] != '0') { $status = new Resque_Job_Status($this->_params['token']); $jobStatus = $status->get(); } $status = new Resque_Job_Status($this->_params['token']); $response = array('status' => $movie->status, 'statusLabel' => $this->getStatusLabel($movie->status), 'queuePosition' => $queueNum, 'currentFrame' => 0, 'jobStatus' => $jobStatus); } else { if ($movie->status == 1) { $current_frame = $movie->getCurrentFrame(); $progress = $current_frame / $movie->numFrames; $progress = (double) number_format($progress, 3); $response = array('status' => $movie->status, 'statusLabel' => $this->getStatusLabel($movie->status), 'currentFrame' => $current_frame, 'numFrames' => $movie->numFrames, 'progress' => $progress, 'queuePosition' => $queueNum); } else { if ($movie->status == 2) { // FINISHED $response = $movie->getCompletedMovieInformation($verbose); $response['statusLabel'] = $this->getStatusLabel($response['status']); } else { if ($movie->status == 3) { // ERROR $response = array('status' => $movie->status, 'statusLabel' => $this->getStatusLabel($movie->status), 'error' => 'Sorry, we are unable to create your movie at ' . 'this time. Please try again later.'); } else { $response = array('status' => $movie->status, 'statusLabel' => $this->getStatusLabel($movie->status), 'queuePosition' => $queueNum); } } } } $this->_printJSON(json_encode($response)); }