function ajax_loadVideosMigration(Request $request) { if (!$request->ajax()) { return; } $data = $request->all(); $skip = $data["skip"]; $return = array(); $chapters = Chapter::where("videocloud_id", $data["videocloud_id"])->skip($skip)->take(30)->orderBy("id", "DESC")->get(); foreach ($chapters as $chapter) { $video = new Video($chapter->video); $return[] = array("id" => $chapter->id, "url" => $video->getUrlVideo()); } return json_encode($return); }
/** Recibe una peticion con token de un unico uso que retornara la url de la fuente del video * * @param type $token Token de la reproduccion generada anteriormente * @param type $id_video El id del video * @return type */ function getVideoSource($token, $id_video, $time) { //Tiempo de paja // sleep(2); $playback = Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_TOKEN, $token)->get(); //Verifica que el token de peticion exista if (count($playback) == 0) { return abort(404); } $playback = $playback[0]; //Verifica que el token no haya sido validado if (intval($playback->pivot->validate) >= 2) { return abort(404); } //Valida el token de reproduccion if ($time > 0) { Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_TOKEN, $token)->update(array(User::ATTR_PLAYBACKS_PIVOT_VALIDATE => intval($playback->pivot->validate) + 1)); } else { Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_TOKEN, $token)->update(array(User::ATTR_PLAYBACKS_PIVOT_VALIDATE => 2)); } $detect = new MobileDetect(); $video = new Video($id_video); if ($detect->isMobile() || $detect->isTablet()) { $url_video = $video->getUrlVideoPlayer(); } else { //Entrega la URL del video $url_video = $video->getUrlVideo(); } header("HTTP/1.1 301 Moved Permanently"); header("Location: {$url_video}"); header("Connection: close"); }