Ejemplo n.º 1
0
 /**
  * Contructs Video Details object from JSON
  * @param <type> $data
  * @return VideoDetails
  */
 static function fromJson($data)
 {
     $jo = json_decode($data);
     //error messages comes in format like this: "{"error":"In progress"}"
     if ($jo == NULL) {
         return NULL;
     } else {
         $vid = new VideoDetails();
         if (array_key_exists('error', $jo)) {
             if (strpos($jo->error, 'progress')) {
                 $vid->type = 'video';
                 $vid->videoStatus = VideoStatus::PROCESSING;
                 $vid->videoStatusDescription = VideoStatusDescriptions::PROCESSING;
             }
         } else {
             if (array_key_exists('vzaar-api', $jo)) {
                 $vars = get_object_vars($jo);
                 if (array_key_exists('error', $vars['vzaar-api'])) {
                     throw new VzaarException($vars['vzaar-api']->error->type);
                 } else {
                     $vid->videoStatus = $vars['vzaar-api']->video->video_status_id;
                     $vid->videoStatusDescription = $vars['vzaar-api']->video->state;
                 }
             } else {
                 $vid->authorAccount = $jo->author_account;
                 $vid->authorName = $jo->author_name;
                 $vid->authorUrl = $jo->author_url;
                 $vid->borderless = array_key_exists('borderless', $jo) ? $jo->borderless : NULL;
                 $vid->description = array_key_exists('description', $jo) ? $jo->description : NULL;
                 $vid->duration = array_key_exists('duration', $jo) ? $jo->duration : NULL;
                 $vid->framegrabHeight = array_key_exists('framegreb_height', $jo) ? $jo->framegreb_height : NULL;
                 $vid->framegrabUrl = array_key_exists('framegrab_url', $jo) ? $jo->framegrab_url : NULL;
                 $vid->framegrabWidth = array_key_exists('framegrab_width', $jo) ? $jo->framegrab_width : NULL;
                 $vid->height = $jo->height;
                 $vid->html = $jo->html;
                 $vid->providerName = $jo->provider_name;
                 $vid->providerUrl = $jo->provider_url;
                 $vid->thumbnailHeight = array_key_exists('thumbnail_height', $jo) ? $jo->thumbnail_height : NULL;
                 $vid->thumbnailUrl = array_key_exists('thumbnail_url', $jo) ? $jo->thumbnail_url : NULL;
                 $vid->thumbnailWidth = array_key_exists('thumbnail_width', $jo) ? $jo->thumbnail_width : NULL;
                 $vid->title = $jo->title;
                 $vid->playCount = $jo->play_count;
                 $vid->type = $jo->type;
                 $vid->version = $jo->version;
                 $vid->width = $jo->width;
                 $vid->videoStatus = array_key_exists('video_status_id', $jo) ? $jo->video_status_id : 0;
                 $vid->videoStatusDescription = array_key_exists('video_status_description', $jo) ? $jo->video_status_description : '';
                 $vid->renditions = VideoDetails::parseRenditions($jo->renditions);
                 $vid->totalSize = $jo->total_size;
             }
         }
         return $vid;
     }
 }
Ejemplo n.º 2
0
 /**
  * vzaar uses the oEmbed open standard for allowing 3rd parties to
  * integrated with the vzaar. You can use the vzaar video URL to easily
  * obtain the appropriate embed code for that video
  * @param integer $id is the vzaar video number for that video
  * @param bool $auth Use authenticated request if true
  * @return VideoDetails
  */
 public static function getVideoDetails($id, $auth = false)
 {
     $_url = self::$url . 'api/videos/' . $id . '.json';
     $req = new HttpRequest($_url);
     $req->verbose = Vzaar::$enableHttpVerbose;
     if ($auth) {
         array_push($req->headers, Vzaar::setAuth($_url, 'GET')->to_header());
     }
     /*
      * we change this, send as pure and we'll let
      * laravel deal with response
      */
     //dd($req->send());
     //return $req->send();
     //return json_decode($req->send());
     return VideoDetails::fromJson($req->send());
 }