/** 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");
 }