public static function get($room) { //get all servers meeting existed and check for recordings $bbb_servers = $room->meetings()->groupBy('bbb_server')->get(['bbb_server']); $recordings = array(); foreach ($bbb_servers as $bbb_server) { $bbb = new BigBlueButton($bbb_server->bbb_server); //if server is not up do not bring recordings and continue to next server if (!$bbb->isUp()) { continue; } $recordingsParams = array('meetingId' => $room->bbb_meeting_id); $result = $bbb->getRecordingsWithXmlResponseArray($recordingsParams); $isOwner = roomController::checkOwner($room); foreach ($result as $recording) { if ($recording['playbackFormatUrl'] != null) { $duration_sec = $recording['endTime'] - $recording['startTime']; //create download url $parse_url = parse_url($recording['playbackFormatUrl']); $download_url = 'http://' . $parse_url['host'] . '/playback/presentation/download/' . $recording['recordId'] . '.zip'; $duration = gmdate("H:i:s", substr($duration_sec, 0, -3)); //find if we know recording $rec_query = Recording::where('rid', $recording['recordId'])->first(); //if we dont just save if (!$rec_query) { $rec_ins = new Recording(); $rec_ins->rid = $recording['recordId']; $rec_ins->published = 0; $rec_ins->keep = 0; $rec_ins->bbb_server_id = $bbb->id; $rec_ins->owner = $room->owner; $rec_ins->save(); //new recording show only to owner if ($isOwner) { $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => false, 'portal_id' => $rec_ins->id, 'published' => false); } } else { if ($rec_query->published || $isOwner) { $recordings[] = array('id' => $recording['recordId'], 'url' => $recording['playbackFormatUrl'], 'time' => date('d/m/Y H:i', substr($recording['startTime'], 0, -3)), 'duration' => $duration, 'time_real' => $recording['startTime'], 'download_url' => $download_url, 'server_id' => $bbb->id, 'keep' => $rec_query->keep, 'portal_id' => $rec_query->id, 'published' => $rec_query->published); } } } } } if (!empty($recordings)) { usort($recordings, function ($a, $b) { return $b['time_real'] - $a['time_real']; }); return $recordings; } else { return null; } }