Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 /** 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 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);
 }
 function getPlayChapter($slug, $id_chapter)
 {
     $id_chapter = Hash::decrypt(urldecode($id_chapter));
     $production = Production::where(Production::ATTR_SLUG, $slug)->get();
     if (count($production) == 0) {
         //Verifica en el log el slug
         if (is_null($id = Slug::getIdProduction($slug))) {
             return abort(404);
         } else {
             return redirect("production/" . Production::findOrNew($id)->slug . "/play");
         }
     }
     $production = $production[0];
     //Verifica que el id del capitulo exista
     if (Chapter::where(Chapter::ATTR_ID, $id_chapter)->count() == 0 || !is_numeric($id_chapter)) {
         return redirect("production/" . $production->slug);
     }
     //Verifica si la pelicula esta activa
     if ($production->state != Production::STATE_ACTIVE) {
         return redirect("production/" . $slug);
     }
     if (Auth::user()->state != User::STATE_ACTIVED_ACCOUNT) {
         return view("frontend/contents/production/play-forbbiden")->with("production", $production)->with("title", "¡ACTIVA TU CUENTA!")->with("message", view("ui/msg/contents/activa-tu-cuenta")->render());
     }
     //Obtiene los datos de la ultima reproduccion del usuario
     list($play_date, $play_ip, $play_production, $play_chapter) = Auth::user()->getLastPlayBack();
     //Verifica la restriccion de usuario gratis, en la que solo permite ver una pelicula por dia
     if (Auth::user()->role == User::ROLE_SUSCRIPTOR) {
         if (!is_null($play_production)) {
             /**
              * EL usuario gratis tiene 24 horas para ver la produccion que escogio
              */
             $play_date = new DateUtil($play_date);
             //Agrega un dia, para determinar la proxima reproduccion
             $play_date->addDays(1);
             $next_date = $play_date->year . "-" . DateUtil::numberAdapt($play_date->month) . "-" . DateUtil::numberAdapt($play_date->day) . " 00:00:00";
             //Calcula la diferencia de tiempo entre el tiempo actual y la fecha de la proxima reproduccion
             $time = DateUtil::difSec(DateUtil::getCurrentTime(), $next_date);
             if ($time > 0 && $id_chapter != $play_chapter) {
                 return view("frontend/contents/production/play-forbbiden")->with("production", $production)->with("message", view("ui/msg/contents/play-forbidden-production-in-play")->with("production", Production::find($play_production))->with("time", $time)->with("chapter", Chapter::find($play_chapter))->render())->with("script", "assets/plugins/countdown/js/countdown.js")->with("css", array("assets/plugins/countdown/css/styles.css"));
             }
         }
     }
     $id_video = Chapter::find($id_chapter)->video;
     return view("ui/media/videoplayer")->with("production", $production)->with("id_video", $id_video);
 }