Beispiel #1
0
        public static void Create(IHTMLDiv Container, int width, int height, Action <YouTubePlayer> handler)
        {
            var Context = Container.Token.Context;

            var n = new YouTubePlayer {
                id = Context.CreateToken()
            };

            if (Create_onYouTubePlayerReady_token == null)
            {
                Create_onYouTubePlayerReady_token = Context.CreateToken();
                Create_onYouTubePlayerReady_token.External(
                    (string id) =>
                {
                    if (Create_onYouTubePlayerReady != null)
                    {
                        Create_onYouTubePlayerReady(id);
                    }
                }
                    );

                1.ExternalAtDelay(
                    "window['onYouTubePlayerReady'] = function (_id) {document.getElementById('" + Context.Element.id + "')['" + Create_onYouTubePlayerReady_token + "'](_id); };"
                    );
            }

            Container.innerHTML = @"<object 
				type='application/x-shockwave-flash' 
				data='http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid="                 + n.id + @"' 
				width='"                 + width + @"' 
				height='"                 + height + @"' 
				
				wmode='window' 
				id='"                 + n.id + @"'
				name='"                 + n.id + @"'
			
				allowFullScreen='true' 
				allowNetworking='all' 
				allowScriptAccess='always'>
			  <param name='movie' value='http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid="             + n.id + @"' />
			</object>"            ;

            n.Token.Context = Container.Token.Context;

            Create_onYouTubePlayerReady +=
                id =>
            {
                if (n == null)
                {
                    return;
                }

                if (id == n.id)
                {
                    handler(n);
                    n = null;
                }
            };
        }
        public static void Create(IHTMLDiv Container, int width, int height, Action<YouTubePlayer> handler)
        {
            var Context = Container.Token.Context;

            var n = new YouTubePlayer { id = Context.CreateToken() };

            if (Create_onYouTubePlayerReady_token == null)
            {
                Create_onYouTubePlayerReady_token = Context.CreateToken();
                Create_onYouTubePlayerReady_token.External(
                    (string id) =>
                    {
                        if (Create_onYouTubePlayerReady != null)
                            Create_onYouTubePlayerReady(id);
                    }
                );

                1.ExternalAtDelay(
                    "window['onYouTubePlayerReady'] = function (_id) {document.getElementById('" + Context.Element.id + "')['" + Create_onYouTubePlayerReady_token + "'](_id); };"
                );
            }

            Container.innerHTML = @"<object
                type='application/x-shockwave-flash'
                data='http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=" + n.id + @"'
                width='" + width + @"'
                height='" + height + @"'

                wmode='window'
                id='" + n.id + @"'
                name='" + n.id + @"'

                allowFullScreen='true'
                allowNetworking='all'
                allowScriptAccess='always'>
              <param name='movie' value='http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=" + n.id + @"' />
            </object>";

            n.Token.Context = Container.Token.Context;

            Create_onYouTubePlayerReady +=
                id =>
                {
                    if (n == null)
                        return;

                    if (id == n.id)
                    {
                        handler(n);
                        n = null;
                    }
                };
        }