Closed kittsville closed 8 years ago
Once the API is loaded a callback sets the video as loaded and calls loadVideo which uses the videoID/startTime properties. It doesn't matter if there's a callback from a previous request waiting to be called as it's not tied to any specific YouTube video. It simply triggers the loading of whatever is the current video.
This does have possible issues if the plugin being used is changed before the API request completes. Image the following timelines:
The anonymous callback that the YouTube API calls should probably be a YTPlugin method set as a global function. It'd make it more readable than an anonymous callback created inside a condition's block.
The current handling of the YouTube iFrame API means that under certain, unlikely, circumstances a video will not be loaded. These circumstances require the iFrame API to be currently loading but not complete. A simple
else
condition that changes the onload of the API to load the new video would solve this.