Il gestore di eventi onError ritorna event.data = 0, in genere per i video rimossi o privati (anche se non ho ancora testato tutti i casi), piuttosto che i valori di errore documentati su YouTube IFrame API Reference (https://developers.google.com/youtube/iframe_api_reference#Events)Che cosa significa YouTube IFrame API onError value of 0?
onError
Questo evento incendi in caso di errore nel lettore. L'API passerà un oggetto evento alla funzione listener dell'evento. La proprietà data di quell'oggetto specificherà un numero intero che identifica il tipo di errore che si è verificato. I valori possibili sono:
2 – The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks. 5 – The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred. 100 – The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private. 101 – The owner of the requested video does not allow it to be played in embedded players. 150 – This error is the same as 101. It's just a 101 error in disguise!
Ciò sta accadendo su Mac OS X, in Chrome, Firefox e Safari, le versioni più recenti. Ecco un link a un video rimosso che restituisce questo codice di errore quando incorporato utilizzando l'API IFrame: http://www.youtube.com/watch?v=-TefH2gu9-o
Testing questo video nel Player API Demo restituisce anche 0 (per il giocatore AS3; quando si seleziona IFrame, restituisce [object Object]
e non è ispezionabile).
Il codice di errore previsto è 100 o superiore.
Solo per il follow-up, ho eseguito il debug della pagina Demo dell'API Player con l'opzione IFrame selezionata in Chrome Dev Tools, restituisce anche event.data = 0 per il video specificato e restituisce '[oggetto oggetto]' perché il codice in onPlayerError non si aspetta o non si difende da un valore di 0 che viene restituito. Quindi posso solo supporre che questo sia un bug che è stato introdotto nell'API qualche tempo fa e che deve ancora essere risolto. Dato che questo è l'unico modo per segnalare questi problemi per l'API di YouTube ora, gradirei una risposta al riguardo. –
Il bug esiste ancora nel momento in cui lo sto pubblicando. Ho provato a riprodurre il video a prescindere e il suo difetto. Strano che sul sito stesso funzioni. Inoltre, non è un problema di video privato perché posso visualizzare il video su YouTube senza essere connesso. – Discipol