YouTube Player API

Posted by Ian / January 14, 2010, 7:07 pm

player

The YouTube ActionScript Player API allows you to play videos hosted on YouTube in your own custom player or as part of a larger Flash site. We’re currently working on a project for Diesel which involves a recruitment phase to source participants for a music video slash online experience. This utilises a video hosted on YouTube and the API presented a great option to avoid duplicating the video resource, while also being able to customise the player design to match brand guidelines.

The API is pleasingly simple, yet no classes or interfaces are provided. This essentially means that you have to cast the loaded player to the dynamic Object class and access methods and properties as dynamic members. This is not particularly nice or easy to work with, as you have to rely heavily on documentation and your code will be highly vulnerable to runtime errors. As the player API looked like something we’d be likely to use again I coded a reusable wrapper to manage it and stored values for states, event types and video quality as constants.

Feel free to reuse the code. Download the source on our new Google code repository at http://code.google.com/p/stinkdigital-flash/. For usage example see http://code.google.com/p/stinkdigital-flash/wiki/YouTubePlayer.

You can see the player in action on diesel.com at http://recruit.diesel.com/.

Comment (1)

Leave A Comment