title: Is there a fix for skipping a YouTube video in a playlist, if video is "unavailable"
body: <p>I have an aggregated list (queried from mySql db) of YouTube videos in an HTML 5 media player playlist. But over time, YouTube will disable certain videos due to copyright or judgement issues, but the links are still in my list. Can anyone recommend a JS or other solution or article that sees if the video link does not start in x amount of time to initiate a skip or next action.  Please advise.</p>
  
  <p>No solutions, because extensive googling has no suggestions.</p>
  
  <p>my basic logic is if video does not play after x seconds, then skip, otherwise play.</p>
  
  <pre><code>// THIS ACTUALLY CHECKS PLAYTIME AND ADD TO A COUNTER - CAN I USE SOMETHING SIMILAR?
  
  var counter = 0;
  var currentIndex_inc = 0;
  function onProgress() {
  
  if(player.currentTime() &lt;= 1){
      counter = 0;
  }
  
  //-- ------------------------------------- --&gt;
  // ----- COUNTER - If track plays longer than 30 seconds - add 1 --------
  //-- ------------------------------------- --&gt;
  if(player.currentTime() &gt;= 30  &amp;&amp; trackURL != ''){
      if(counter==0){
      counter = 1;
      var playlist_name = "&lt;?php echo $playlist ; ?&gt;";
      var play_type = "&lt;?php echo $type ; ?&gt;";
      var trackURL = player.currentSrc();
      track_source = trackURL.src ;
  
          if(typeof(track_source)==="undefined"){
           track_source = trackURL;
          };
  
      $.ajax({
          type: "POST",
          url: "_inc/2018_process_counter.php",
          dataType: "text",
              data: { 
                  playlist_name: playlist_name,track_source:track_source }
      }).done(function( data ) {
  });
      }
      return false;
  }
  
  Logic:
  If (video link does not start || video link == live){ 
     skip 
  } else if (video link does start || video link == dead) {
     play 
  }
  </code></pre>
  
  <p>List Code with Queru - based on successful reply. The answer works for a single id but not a list... See my code below:</p>
  
  <pre><code>if ($result_a-&gt;num_rows &gt; 0) {
          // output data of each row
          while($row = $result_a-&gt;fetch_assoc()) {
              $id = $row['id'];
              $share_key = $row['share_key'];
              echo $row['id'];
              echo '&lt;br&gt;';
              echo $row['artist'];
              echo '&lt;br&gt;';
              echo $row['title'];
              echo '&lt;br&gt;';
              echo $row['source_url'];
              echo '&lt;br&gt;';            
              $my_link = $row['source_url'];
  
              $testlink = substr($my_link, strrpos($my_link, '/' )+1)."\n";
  
              echo '&lt;p style="color:#ff0000"&gt;';
              echo $testlink;
              echo '&lt;/p&gt;';            
  
              //# is ERROR = https://www.youtube.com/watch?v=R5mpcDWpYSA
              // $url = "https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=R5mpcDWpYSA"; //# test video deleted.
  
              //# is OK = https://www.youtube.com/watch?v=mLuh_O4mYbA
              $url = "https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=".$testlink; //# test working (not deleted).
              echo $url;
              echo '&lt;br&gt;';
              try
              {
                  set_error_handler(function() { /* # temp ignore Warnings/Errors */ });
  
                  $fop = fopen($url, "rb");
                  if ( !$fop &amp;&amp; $fop==false) { throw new Exception(); }
  
                  restore_error_handler(); //# restore Warnings/Errors
  
                  echo "OK 200 ::: Youtube video was found";
              }
              catch ( Exception $e ) 
              { echo "Error 404 ::: Youtube video not found (deleted or bad link)"; }
  
  
  
  
              echo '&lt;hr&gt;';
  
  
  
  
  
  
  
  
  
          }
      } else {
          // echo "0 results";
      }
  </code></pre>