This is not officially supported in the current Chrome API. YouTube is likely using undocumented features or other DIAL functionality.
This might be of interest: https://github.com/jloutsenhizer/CR-Cast/wiki/Chromecast-Implementation-Documentation-WIP