English | Site Directory

YouTube APIs and Tools

YouTube Chromeless Player Reference

This document provides reference information for the YouTube Chromeless Player.

Contents

Overview

The YouTube Chromeless Player gives developers the flexibility to customize the YouTube player with their own controls, player 'chrome', and even behaviors like custom playlists and menus.

Requirements

The end user must have Flash Player 8 or higher installed. Because of this requirement, we suggest using SWFObject to embed the SWF and detect the user's Flash Player version.

Getting Started

First off, you need a developer key. To register for one, visit the registration page.

The chromeless player consists of two SWF files. apiplayer.SWF contains the actual video playing functionality. cl.SWF is a loader SWF that loads apiplayer.SWF and exposes the player's API functions. It also provides security sandbox restrictions for the apiplayer.SWF, so loading SWFs cannot access elements inside the player directly.

The player can be controlled via two methods — by loading the SWF into another SWF (or Flash website, etc.), or by embedding it directly in an HTML page and using JavaScript to control the player. The JavaScript controls are identical to the embedded player's JavaScript API.

The URL to load the chromeless player SWF is:

http://gdata.youtube.com/apiplayer?key=DEV_KEY

Functions

The following operations are available in addition to the ones listed in the JavaScript API documentation.

loadVideoById(videoId:String, startSeconds:Number):Void
Load the specified video and starts playing the video. If startSeconds (number can be a float) is specified, the video will start from the closest keyframe to the specified time.
cueVideoById(videoId:String, startSeconds:Number):Void
Loads the specified video's thumbnail and prepares the player to play the video. The player does not request the FLV until playVideo() or seekTo() is called. startSeconds accepts a float/integer and specifies the time that the video should start playing from when playVideo() is called. If you specify startSeconds and then call seekTo(), the startSeconds is forgotten and the player plays from the time specified in the seekTo() call. When the video is cued and ready to play, the player will broadcast a video cued event (5).
setSize(width:Number, height:Number):Void
Sets the size of the chromeless player. This method should be used in favor of setting the width + height of the MovieClip directly. Note that this method does not constrain the proportions of the video player, so you will need to maintain a 4:3 aspect ratio. When embedding the player directly in HTML, the size is updated automatically to the Stage.width and Stage.height values, so there is no need to call setSize() when embedding the chromeless player directly into an HTML page. The default size of the SWF when loaded into another SWF is 320px by 240px.

Examples

Using the JavaScript API

When embedding the chromeless player into an HTML page, enable the JavaScript API by appending a variable to the URL of the SWF:

http://gdata.youtube.com/apiplayer?key=dev_key&enablejsapi=1

For a list of the available API methods and examples of using the JavaScript API, see the reference documentation.

An example of the chromeless player using the JavaScript API can be found here.

Loading the player into another SWF

For information on loading the chromeless player into another SWF, see the ActionScript 2.0 documentation. All of the API calls are the same, with the addition of the ones outlined above.

Back to top