Skip to content

Instantly share code, notes, and snippets.

@andhikanugraha
Created April 13, 2016 07:38
Show Gist options
  • Save andhikanugraha/b3a761754fa167a3bedf2c170e890de7 to your computer and use it in GitHub Desktop.
Save andhikanugraha/b3a761754fa167a3bedf2c170e890de7 to your computer and use it in GitHub Desktop.
Azure Media Services SDK for PHP: Task progress & error details
<?php
// When creating a Task...
$task = new Task(...);
$task = $task->setName('[TASK NAME]');
// Submit the job
$job = $mediaServicesRestProxy->createJob($job, array($asset), array($task));
// To get progress...
// Fetch all task statuses from Azure Media Services API
$tasks = $mediaServicesRestProxy->getTaskList();
foreach ($tasks) {
// Find which task we're looking for
if ($tasks->getName() === '[TASK NAME]') {
// Get the progress
$progress = $task->getProgress(); // returns percentage
}
}
// To get error details...
// Fetch all task statuses from Azure Media Services API
$tasks = $mediaServicesRestProxy->getTaskList();
foreach ($tasks) {
// Find which task we're looking for
if ($tasks->getName() === '[TASK NAME]') {
// Get the error details
$errorDetails = $task->getErrorDetails(); // returns array of errordetails
foreach ($errorDetails as $error) {
$code = $error->getCode();
$message = $error->getMessage();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment