function __construct($id_video) { $this->id_video = intval(trim($id_video)); $videocloud = VideoCloudAccount::find(Chapter::where(Chapter::ATTR_VIDEO, $id_video)->get()[0]->videocloud_id); $this->token = $videocloud->token; $this->player = $videocloud->player; }
/** Obtiene un html en un formato standar para mostrar la produccion * * @param type $production (Production) El objeto de production * @return type */ static function getVisualHtml(Production $production, $classname = "production", $classimage = "img-rounded") { $isVideoMain = $production->haveVideoMain(); $html = "<div class='" . $classname . "'>"; $html .= "<a "; if (Auth::check()) { $html .= "onClick='modalProduction(\"" . $production->id . "\");'"; } else { $html .= "href='" . url("production/" . $production->slug) . "'"; } $html .= ">"; //Si la produccion es una serie incrustar la información de los capitulos if (!$isVideoMain) { $chapters = Chapter::where(Chapter::ATTR_PRODUCTION_ID, $production->id)->get(); $json = array(); foreach ($chapters as $chapter) { $json[] = array($chapter->name, url("production/" . $production->slug . "/play/" . urlencode(\App\System\Library\Security\Hash::encrypt($chapter->id)))); } $html .= "<span class='hidden' id='chapters-" . $production->id . "'>" . json_encode($json) . "</span>"; } $html .= "<span class='hidden' id='url-" . $production->id . "'>" . url("production/" . $production->slug) . "</span><img id='img-production-" . $production->id . "' title='" . $production->title . "' class='" . $classimage; $html .= $production->state != Production::STATE_ACTIVE ? " production-not-available" : ""; $html .= "' src='" . Util::convertToSecureUrl($production->image) . "'><div class='over'><span class='glyphicon glyphicon-play-circle'></span>" . $production->title . "</div>" . "</a>" . "</div>"; return $html; }
function ajaxDeleteChapter(Request $request) { if (!$request->ajax()) { return; } $data = $request->all(); Chapter::findOrNew($data[Chapter::ATTR_ID])->delete(); return json_encode(array()); }
/** Recibe una peticion ajax, para generar una url de video con una token especial * * @param Request $request * @return type */ function ajax_getVideoUrl(Request $request) { if (!$request->ajax()) { return; } //Evita que se un usuario pueda reproducir dos videos al mismo tiempo //NOTA: Esta funcion no se puede implementar, porque el evento onbeforeunload de javascript no funciona del todo en Google Chrome (Buscar una alternativa) /* if (Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_RUNNING, true)->count() > 0) return json_encode(array("error" => "<span style='font-size: 60pt;color: red;' class='glyphicon glyphicon-ban-circle'></span><br/>Lo sentimos, pero no puedes reproducir este contenido, por que esta cuenta ya se esta usando.")); */ //Tiempo de paja //sleep(3); $data = $request->all(); //Verifica que el token no se repite do { $token = Hash::generateToken(100); } while (Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_TOKEN, $token)->count() > 0); if (strlen($data["token_video"]) > 2) { $parent_play = Auth::user()->playbacks()->where(User::ATTR_PLAYBACKS_PIVOT_TOKEN, $data["token_video"])->get(); if (count($parent_play) > 0) { $parent_play = $parent_play[0]; $parent = $parent_play->pivot->id; } else { return json_encode(array("error" => "Bad Request")); } } else { $parent = 0; } //Obtiene la información del video $chapter = Chapter::firstOrNew([Chapter::ATTR_VIDEO => $data["id_video"]]); //Genera un registro de reproduccion y token de validacion Auth::user()->playbacks()->attach($data["production_id"], array(User::ATTR_PLAYBACKS_PIVOT_CHAPTER_ID => $chapter->id, User::ATTR_PLAYBACKS_PIVOT_IP => Util::getIP(), User::ATTR_PLAYBACKS_PIVOT_DATE => DateUtil::getCurrentTime(), User::ATTR_PLAYBACKS_PIVOT_TOKEN => $token, User::ATTR_PLAYBACKS_PIVOT_PARENT => $parent, User::ATTR_PLAYBACKS_PIVOT_USER_AGENT => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null)); return json_encode(array("url" => url("get/source/video/" . $token . "/" . $data["id_video"]), "token" => $token)); }
<?php use App\System\Models\Chapter; use App\System\Library\Complements\Util; use App\System\Models\VideoCloudAccount; $langs = App\System\Library\Enum\Language::getAll(); $qualities = Chapter::getQualities(); $subs = Chapter::getSubtitles(); $chapters = $production->chapters; $isVideoMain = $production->haveVideoMain(); if ($isVideoMain) { $chapter = $chapters[0]; } $videocloud = !isset($chapter) ? VideoCloudAccount::getCurrentAccountEmail() : VideoCloudAccount::getAccountEmailById($chapter->videocloud_id); ?> @extends("manager/ui/templates/main") @section("title") {{trans("gen.info.edit")}}: {{$production->title}}@stop @section("content") <div class="col-md-12"> <div class="col-md-8"> @include("ui/msg/index",array("message_id"=>2)) </div> <div class="col-md-4"> <nav class="navbar navbar-default"> <div class="navbar-header"> <a class="navbar-brand" href="#"><span class="glyphicon glyphicon-save"></span> {{trans("gen.info.as.save")}}:</a>