/**
  * YouTubeBlockService constructor.
  * @param string $name
  * @param EngineInterface $templating
  * @param YouTubeApiService $youTubeApi
  * @param RequestStack $requestStack
  * @param GoogleRedirectService $redirectService
  * @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException
  */
 public function __construct($name, EngineInterface $templating, YouTubeApiService $youTubeApi, RequestStack $requestStack, GoogleRedirectService $redirectService)
 {
     $this->youTubeApi = $youTubeApi;
     $this->requestStack = $requestStack;
     $redirectUri = $redirectService->getOAuthRedirectUrl();
     $this->youTubeApi->initApiClients($redirectUri);
     parent::__construct($name, $templating);
 }
 /**
  * YouTubeSwitchMonitorListener constructor.
  * @param SchedulerCommandsInterface $command
  * @param StreamOutputService $outputService
  * @param StreamInputService $inputService
  * @param YouTubeApiService $youTubeApiService
  * @param GoogleRedirectService $redirectService
  * @param LoggerInterface $logger
  * @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException
  */
 public function __construct(SchedulerCommandsInterface $command, StreamOutputService $outputService, StreamInputService $inputService, YouTubeApiService $youTubeApiService, GoogleRedirectService $redirectService, LoggerInterface $logger)
 {
     $this->command = $command;
     $this->outputService = $outputService;
     $this->inputService = $inputService;
     $this->youTubeApiService = $youTubeApiService;
     $this->logger = $logger;
     $redirectUri = $redirectService->getOAuthRedirectUrl();
     $this->youTubeApiService->initApiClients($redirectUri);
 }
 /**
  * @param PostBroadcastEvent $event
  */
 public function onPostBroadcast(PostBroadcastEvent $event)
 {
     /** @var LiveBroadcast $liveBroadcast */
     $liveBroadcast = $event->getLiveBroadcast();
     $output = $event->getOutput();
     if ($output instanceof OutputYouTube) {
         $redirectUri = $this->redirectService->getOAuthRedirectUrl();
         $this->youTubeApiService->initApiClients($redirectUri);
         $channel = $output->getChannel();
         $this->youTubeApiService->transitionState($liveBroadcast, $channel, YouTubeEvent::STATE_REMOTE_LIVE);
     }
 }
 /**
  * @param PreBroadcastEvent $event
  */
 public function onPreBroadcast(PreBroadcastEvent $event)
 {
     /** @var LiveBroadcast $liveBroadcast */
     $liveBroadcast = $event->getLiveBroadcast();
     $output = $event->getOutput();
     if ($output instanceof OutputYouTube) {
         $redirectUri = $this->redirectService->getOAuthRedirectUrl();
         $this->youTubeApiService->initApiClients($redirectUri);
         $streamUrl = $this->youTubeApiService->getStreamUrl($liveBroadcast, $output->getChannel());
         if ($streamUrl) {
             $output->setStreamUrl($streamUrl);
         }
     }
 }
 /**
  * @return YouTubeApiService
  * @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException
  */
 protected function getYouTubeApiService()
 {
     if (!$this->googleRedirectUri) {
         $this->googleRedirectUri = $this->redirectService->getOAuthRedirectUrl();
         $this->youTubeApiService->initApiClients($this->googleRedirectUri);
     }
     return $this->youTubeApiService;
 }