Как пропустить приватные видео в YouTube плейлист для вставки - PullRequest
2 голосов
/ 09 ноября 2019

Мы используем следующий код, чтобы встроить последнее видео YouTube в один из наших плейлистов. Мы поставили видео в очередь, чтобы запустить его завтра, и теперь на нашем веб-сайте отображается ошибка «Видео недоступно - видео закрыто». Мы проверили API, но я не вижу плееров, которые пропускали бы приватные видео.

Есть идеи, как получить базовый плейлист Youtube для пропуска приватных или не встраиваемых видео?

        <div id="muteYouTubeVideoPlayer"></div>

        <script async src="https://www.youtube.com/iframe_api"></script>
        <script>
         function onYouTubeIframeAPIReady() {
          var player;
          player = new YT.Player('muteYouTubeVideoPlayer', {
            width: 940,               // Player width (in px)
            height: 530,              // Player height (in px)
            playerVars: {
              listType:'playlist',
              list: '{{LIST_ID}}',
              autoplay: 1,        // Auto-play the video on load
              controls: 1,        // Show pause/play buttons in player
              showinfo: 0,        // Hide the video title
              modestbranding: 1,  // Hide the Youtube Logo
              loop: 1,            // Run the video in a loop
              fs: 0,              // Hide the full screen button
              cc_load_policy: 0, // Hide closed captions
              iv_load_policy: 3,  // Hide the Video Annotations
              autohide: 0         // Hide video controls when playing
            },
            events: {
              onReady: function(e) {
                e.target.mute();
              }
            }
          });
         }
        </script>

Я также попытался добавить немного для воспроизведения следующего видео, если есть ошибка. Он переключается на следующий элемент в списке воспроизведения, но не воспроизводит его.

        <div id="muteYouTubeVideoPlayer"></div>

        <script async src="https://www.youtube.com/iframe_api"></script>
        <script>
         function onYouTubeIframeAPIReady() {
          var player;
          player = new YT.Player('muteYouTubeVideoPlayer', {
            width: 940,               // Player width (in px)
            height: 530,              // Player height (in px)
            playerVars: {
              listType:'playlist',
              list: '{{LIST_ID}}',
              autoplay: 1,        // Auto-play the video on load
              controls: 1,        // Show pause/play buttons in player
              showinfo: 0,        // Hide the video title
              modestbranding: 1,  // Hide the Youtube Logo
              loop: 1,            // Run the video in a loop
              fs: 0,              // Hide the full screen button
              cc_load_policy: 0, // Hide closed captions
              iv_load_policy: 3,  // Hide the Video Annotations
              autohide: 0         // Hide video controls when playing
            },
            events: {
              onReady: function(e) {
                e.target.mute();
              },
              onError: function(e){
                e.target.nextVideo();
                e.target.playVideo();
              }
            }
          });
         }
        </script>
...