Currently YoutubeVideo defines canHandleURL to declare whether it can handle the Flash instance, by checking that the Flash movie matches ^http://www.youtube.com/v/.
To add support for new video services, this simple detection mechanism would not be enough. For example, some video players can be installed by the webmaster and therefore can have arbitrary names. More reliable detection for these players would be based on "flash args".
So instead of canHandleURL, we can just have a generic canHandle function. I propose passing the following information to it, as key-value pairs:
playerUrl: URL to the Flash movie, as in the current canHandleURL
domNode: the OBJECT or EMBED node for the Flash plugin
flashArgs: the "flash args" defined on OBJECT or EMBED/PARAM, parsed into key-value pairs. This might not be useful for some video handlers such as the current YoutubeVideo, but it seems that YouTube embed code typically does not contain flash args anyway, so there is little extra overhead. Alternatively, We can provide a helper function to parse flash args, or just let individual video handlers implement it if there is little reuse.
This detection is mainly used to dispatch Flash instances into the right video handlers. For each Flash, each handler will say if they can handle it, and as soon as one handler can handle it, other handlers will be skipped for the same Flash. So if a video handler thinks it can handle the Flash instance but later finds out it cannot, it can just stop without replacing the Flash plugin with a video tag, and no harm is done unless the plugin could have been handled by another video handler.
Currently YoutubeVideo defines
canHandleURLto declare whether it can handle the Flash instance, by checking that the Flash movie matches ^http://www.youtube.com/v/.To add support for new video services, this simple detection mechanism would not be enough. For example, some video players can be installed by the webmaster and therefore can have arbitrary names. More reliable detection for these players would be based on "flash args".
So instead of
canHandleURL, we can just have a genericcanHandlefunction. I propose passing the following information to it, as key-value pairs:playerUrl: URL to the Flash movie, as in the currentcanHandleURLdomNode: the OBJECT or EMBED node for the Flash pluginflashArgs: the "flash args" defined on OBJECT or EMBED/PARAM, parsed into key-value pairs. This might not be useful for some video handlers such as the current YoutubeVideo, but it seems that YouTube embed code typically does not contain flash args anyway, so there is little extra overhead. Alternatively, We can provide a helper function to parse flash args, or just let individual video handlers implement it if there is little reuse.This detection is mainly used to dispatch Flash instances into the right video handlers. For each Flash, each handler will say if they can handle it, and as soon as one handler can handle it, other handlers will be skipped for the same Flash. So if a video handler thinks it can handle the Flash instance but later finds out it cannot, it can just stop without replacing the Flash plugin with a video tag, and no harm is done unless the plugin could have been handled by another video handler.