My favorites
▼
|
Sign in
gdata-samples
Google Data API Samples
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
ytplayer
/
YTDemo.as
r248
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class YTDemo {
// create a MovieClip to load the player into
var ytplayer:MovieClip = _root.createEmptyMovieClip("ytplayer", 1);
// create a listener object for the MovieClipLoader to use
var ytPlayerLoaderListener:Object = {
onLoadInit: function() {
// When the player clip first loads, we start an interval to check for when the
// player is ready
this.loadInterval = setInterval(this.checkPlayerLoaded, 250);
}
};
var loadInterval:Number;
function checkPlayerLoaded():Void {
// once the player is ready, we can subscribe to events, or in the case of
// the chromeless player, we could load videos
if (ytplayer.isPlayerLoaded()) {
ytplayer.addEventListener("onStateChange", onPlayerStateChange);
ytplayer.addEventListener("onError", onPlayerError);
clearInterval(loadInterval);
}
}
function onPlayerStateChange(newState:Number) {
trace("New player state: "+ newState);
}
function onPlayerError(errorCode:Number) {
trace("An error occurred: "+ errorCode);
}
static var app : YTDemo;
function YTDemo() {
// create a MovieClipLoader to handle the loading of the player
var ytPlayerLoader:MovieClipLoader = new MovieClipLoader();
ytPlayerLoader.addListener(ytPlayerLoaderListener);
// load the player
ytPlayerLoader.loadClip("http://www.youtube.com/v/_UNgokP71tw", ytplayer);
}
// entry point
static function main(mc) {
app = new YTDemo();
}
}
Show details
Hide details
Change log
r159
by api.jfis...@google.com on Feb 25, 2009
Diff
Adding in some sample code for embedding the YouTube player.
Go to:
/trunk/ytplayer
/trunk/ytplayer/YTDemo.as
...ytplayer/basic_youtube_embed.fla
Sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1515 bytes, 53 lines
View raw file
Powered by
Google Project Hosting