kittsville / GifSound-2

Abandoned remake of gifsound.com with modular media plugins and no server-side code
https://sci1.uk/GifSound-2/
GNU General Public License v2.0
4 stars 1 forks source link

Possible unexpected behaviour by YTPlugin #15

Closed kittsville closed 8 years ago

kittsville commented 8 years ago

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.

kittsville commented 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:

  1. User loads GifSound with any gif plugin and the YTPlugin
  2. The YouTube iFrame API is set to load with a callback on completion
  3. Before it loads the user selects a different GifSound using a different sound plugin.
  4. The API finishes loading and the callback triggers loadVideo. The plugin tries to load a video and starts messing with the sound embed.

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.