Ejemplo n.º 1
0
        public static void ToWebString(this Uri e, Action <string> handler)
        {
            var request = new URLRequest(e.ToString());

            request.method = URLRequestMethod.GET;

            var loader = new URLLoader();

            loader.complete +=
                args =>
            {
                handler("" + loader.data);
            };

            loader.ioError +=
                args =>
            {
                handler(null);
            };


            loader.securityError +=
                args =>
            {
                handler(null);
            };

            loader.load(request);
        }
Ejemplo n.º 2
0
        public URLRequest RequestHandler(WebView sender, object identifier, URLRequest initialRequest, URLResponse urlResponse, WebDataSource datasource)
        {
//		if ( ((URL)(initialRequest.urL)).relativeString.ToString().IndexOf("http://monodoc/load?") == 0) {
            // FIXME
            if (initialRequest.URL.AbsoluteString.IndexOf("http://monodoc/load?") == 0)
            {
                string url     = initialRequest.URL.AbsoluteString.Replace("http://monodoc/load?", "");
                string content = "";
                if (url.StartsWith("edit:"))
                {
//				XmlNode edit_node = EditingUtils.GetNodeFromUrl (url, help_tree);
//				Console.WriteLine (edit_node.InnerXml);
                }

                Node n;
                try {
                    content = help_tree.RenderUrl(url, out n);
                } catch (Exception e) {
                    content = "Exception Rendering the requested URL: " + e;
                }
                if (content != null && !content.Equals(""))
                {
                    content = content.Replace("a href='", "a href='http://monodoc/load?");
                    content = content.Replace("a href=\"", "a href=\"http://monodoc/load?");
                    webView.Render(content);
                    addHistoryItem(url);
                }
                return(null);
            }
            return(initialRequest);
        }
Ejemplo n.º 3
0
        //Method that displays the title, status code/description and html from a given URL
        private void displayAll(string url)

        {
            try
            {
                //make sure everything is set to null first as we append things latter
                HTMLDisplay.Text   = null;
                StatusDisplay.Text = null;
                TitleText.Text     = null;
                //using my own class start a URL request
                URLRequest request = new URLRequest();
                //using a library class: create a HttpwebResponse that uses my class to get a Httpresponse
                HttpWebResponse response = request.getHttpResponse(url);
                //puts the html of the response in a variable
                string html = request.getHTML(response);
                //display the html to the main window
                HTMLDisplay.Text += html;
                //get the status of the response and display it in the status display
                StatusDisplay.Text += request.getStatus(response);
                //get the title of the page and display it in the title text box
                TitleText.Text += request.getTitle(html);
                //close the response
                response.Close();
            }
            //incase there is a null referece catch it here
            catch (NullReferenceException ex)
            {
            }
        }
Ejemplo n.º 4
0
        public static void ToWebBitmap(this Uri uri, string Host, Action <Bitmap> handler)
        {
            var x = uri.ToString();

            if (x.StartsWith(Host))
            {
                handler(
                    KnownEmbeddedResources.Default[x.Substring(Host.Length + 1)].ToBitmapAsset()
                    );
                return;
            }

            var e = new Loader();

            var url = new URLRequest(uri.ToString());


            e.contentLoaderInfo.complete +=
                ev =>
            {
                try
                {
                    var v = (Bitmap)e.content;

                    handler(v);
                }
                catch
                {
                }
            };

            e.load(url, Context);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Graphics_beginBitmapFillExample()
        {
            // http://livedocs.adobe.com/flex/3/langref/flash/display/Graphics.html#beginBitmapFill()

            var request = new URLRequest(url);

            loader.load(request);

            loader.contentLoaderInfo.complete += drawImage;
            loader.contentLoaderInfo.ioError  += ioErrorHandler;
        }
Ejemplo n.º 6
0
	void OnURLRequestHandler (URLRequest request)
	{
		string url = request.GetURL();
		if (url.StartsWith(FacebookAppURL))
		{
			// change the url, keeping all parameters intact
			string redirectURL = LocalAppURL + url.Substring(FacebookAppURL.Length);
			request.SetURL(redirectURL);
			return;
		}
	}
        public VerticalScrollerLoader()
        {
            // http://www.iheartactionscript.com/loading-an-external-swf-in-as3/
            // http://kb2.adobe.com/cps/141/tn_14190.html
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");

            var myLoader = new ScriptCoreLib.ActionScript.flash.display.Loader();

            addChild(myLoader);

            var url = new URLRequest("http://zproxy.appspot.com.nyud.net/assets/Bulldog/VerticalScrollerFlash.swf");


            myLoader.load(url);
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public URLRequestHeaderExample()
        {
            // http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html#includeExamplesSummary
            // http://www.judahfrangipane.com/blog/?p=87

            var t = new TextField
            {
                multiline           = true,
                text                = "powered by jsc",
                background          = true,
                width               = 400,
                x                   = 8,
                y                   = 8,
                alwaysShowSelection = true,
            }.AttachTo(this);

            var loader = new URLLoader();

            var header = new URLRequestHeader("XMyHeader", "got milk?");

            t.appendText("\n" + this.loaderInfo.url);
            t.appendText("\nUsing relative path...");

            var request = new URLRequest("../WebForm1.aspx");
            var data    = new DynamicContainer {
                Subject = new URLVariables("name=John+Doe")
            };

            data["age"] = 23;

            request.data   = data.Subject;
            request.method = URLRequestMethod.POST;
            request.requestHeaders.push(header);

            loader.complete +=
                args =>
            {
                t.appendText("\n" + loader.data);
            };

            loader.load(request);



            KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200);
        }
Ejemplo n.º 9
0
        public void DownloadStringAsync(Uri address)
        {
            // testedby
            // X:\jsc.svn\examples\actionscript\Test\TestWebClient\TestWebClient\ApplicationSprite.cs

            var request = new URLRequest(address.ToString())
            {
                method = URLRequestMethod.GET
            };

            var loader = new URLLoader();

            loader.complete +=
                args =>
            {
                var e = new __DownloadStringCompletedEventArgs {
                    Result = "" + loader.data
                };

                DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
            };

            loader.ioError +=
                args =>
            {
                var e = new __DownloadStringCompletedEventArgs {
                    Error = new Exception("ioError")
                };
                DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
            };


            loader.securityError +=
                args =>
            {
                var e = new __DownloadStringCompletedEventArgs
                {
                    Error = new Exception(
                        "securityError " + new { args.errorID, args.text }
                        )
                };
                DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
            };

            loader.load(request);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
 /// </summary>
 public void load(URLRequest request, LoaderContext context)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new Sound object.
 /// </summary>
 public Sound(URLRequest stream, SoundLoaderContext context)
 {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initiates loading of an external MP3 file from the specified URL.
 /// </summary>
 public void load(URLRequest stream)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
 /// </summary>
 public void load(URLRequest request)
 {
     return;
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
 /// </summary>
 public void load(URLRequest request, LoaderContext context)
 {
     return;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates a new Sound object.
 /// </summary>
 public Sound(URLRequest stream)
 {
 }
Ejemplo n.º 16
0
        void Update()
        {
            List <string> completedItems = null;

            foreach (KeyValuePair <string, URLRequest> wwwPair in DownloadList)
            {
                URLRequest wwwReq = wwwPair.Value;

                if (wwwReq.wwwObject.isDone)
                {
                    //下载完成
                    Action <WWW, object> callbacks = (Action <WWW, object>)wwwReq.callbacks;
                    while (callbacks != null && callbacks.GetInvocationList().GetLength(0) > 0)
                    {
                        Action <WWW, object> callback = (Action <WWW, object>)callbacks.GetInvocationList()[0];
                        if (wwwReq.wwwObject.error != null)
                        {
                            Debug.LogWarning(this.name + " : " + wwwReq.wwwObject.error + " , " + wwwReq.Url);
                        }
                        try
                        {
                            callbacks -= callback;
                            //销毁进度监听
                            wwwReq.progressCallbacks -= (Action <WWW>)wwwReq.progressCallbacks.GetInvocationList()[0];
                            callback.Invoke(wwwReq.wwwObject, wwwReq.callbackParmas[0]);
                        }
                        catch (Exception e)
                        {
                            Debug.LogWarning(e);
                        }

                        if (wwwReq.callbackParmas.Count > 0)
                        {
                            wwwReq.callbackParmas.RemoveAt(0);
                        }
                    }

                    if (completedItems == null)
                    {
                        completedItems = new List <string>();
                    }
                    completedItems.Add(wwwPair.Key);
                }
                else
                {
                    //下载过程中
                    if (wwwReq.progressCallbacks != null)
                    {
                        try
                        {
                            if (Time.realtimeSinceStartup - wwwReq.startTime > wwwReq.Timeout)
                            {
                                //超时处理
                                Debug.LogWarning("[Http Service]" + wwwReq.Url + ", TIMEOUT");

                                //下载完成
                                Action <WWW, object> callbacks = (Action <WWW, object>)wwwReq.callbacks;
                                while (callbacks != null && callbacks.GetInvocationList().GetLength(0) > 0)
                                {
                                    Action <WWW, object> callback = (Action <WWW, object>)callbacks.GetInvocationList()[0];
                                    if (wwwReq.wwwObject.error != null)
                                    {
                                        Debug.LogWarning(wwwReq.wwwObject.error);
                                    }
                                    try
                                    {
                                        callbacks -= callback;
                                        //销毁进度监听
                                        wwwReq.progressCallbacks -= (Action <WWW>)wwwReq.progressCallbacks.GetInvocationList()[0];
                                        callback.Invoke(null, wwwReq.Url);
                                    }
                                    catch (Exception e)
                                    {
                                        Debug.LogError(e);
                                    }

                                    if (wwwReq.callbackParmas.Count > 0)
                                    {
                                        wwwReq.callbackParmas.RemoveAt(0);
                                    }
                                }

                                if (completedItems == null)
                                {
                                    completedItems = new List <string>();
                                }
                                completedItems.Add(wwwPair.Key);
                            }
                            else
                            {
                                //更新进度
                                ((Action <WWW>)wwwReq.progressCallbacks.GetInvocationList()[0]).Invoke(wwwReq.wwwObject);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(e);
                        }
                    }
                }
            }

            if (completedItems != null)
            {
                for (int i = 0; i < completedItems.Count; i++)
                {
                    DownloadList.Remove(completedItems[i]);
                }
                completedItems.Clear();
                completedItems = null;
            }
        }
Ejemplo n.º 17
0
        public MySprite1()
        {
            // http://apiwiki.justin.tv/mediawiki/index.php/Live_Video_SWF_Documentation
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");

            // http://apiwiki.justin.tv/mediawiki/index.php/Live_Video_SWF_Documentation

            //var TargetContent = "http://www.justin.tv/widgets/live_api_player.swf?video_height=480&video_width=640&consumer_key=YOUR_API_KEY";

            var TargetContent = "http://www.justin.tv/widgets/live_api_player.swf?video_height=480&video_width=640";

            var ldr    = new Loader();
            var urlReq = new URLRequest(TargetContent);

            var ctx_app = ApplicationDomain.currentDomain;
            var ctx_sec = SecurityDomain.currentDomain;

            ctx_sec = null;
            ctx_app = null;

            __api_play_live = delegate
            {
            };

            ldr.contentLoaderInfo.complete +=
                delegate
            {
                __api_play_live =
                    channel =>
                {
                    ldr.content.api_play_live(channel);
                };

                __api_play_live("nitro301");
                //(ldr.content as dynamic).api.play_live("apidemo");
            };

            var ctx = new LoaderContext(true, ctx_app, ctx_sec);

            sprite2 = new Sprite {
                z = 0.02
            }.AttachTo(this);

            sprite2.mouseChildren = false;

            ldr.AttachTo(sprite2);

            var t = new Timer(1000 / 60);

            t.timer +=
                delegate
            {
                var x = sprite2.x;
                var y = sprite2.y;

                sprite2.transform.matrix3D.appendTranslation(-x, -y, 0);
                sprite2.transform.matrix3D.appendRotation(0.01, Vector3D.Y_AXIS);
                sprite2.transform.matrix3D.appendRotation(0.02, Vector3D.X_AXIS);
                sprite2.transform.matrix3D.appendTranslation(x, y, 0);
            };

            t.start();

            try
            {
                ldr.load(urlReq, ctx);
            }
            catch
            {
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
 /// </summary>
 public void load(URLRequest request)
 {
 }
Ejemplo n.º 19
0
 public Sound(URLRequest stream)
 {
 }
Ejemplo n.º 20
0
        public Task <byte[]> UploadValuesTaskAsync(Uri address, NameValueCollection data)
        {
            // X:\jsc.svn\examples\actionscript\Test\TestWorkerUploadValuesTaskAsync\TestWorkerUploadValuesTaskAsync\ApplicationSprite.cs
            // https://forums.adobe.com/thread/1189679

            var xx = new TaskCompletionSource <byte[]>();

            // X:\jsc.svn\examples\actionscript\Test\TestUploadValuesTaskAsync\TestUploadValuesTaskAsync\ApplicationSprite.cs

            var request = new URLRequest(address.ToString())
            {
                method = URLRequestMethod.POST
            };

            // should we use dynamic instead?
            var x = new DynamicContainer {
                Subject = new URLVariables()
            };

            foreach (var item in data.AllKeys)
            {
                x[item] = data[item];
            }

            // http://stackoverflow.com/questions/12774611/urlrequest-urlloader-auto-converting-post-request-to-get
            // !!!!
            request.data = (object)x.Subject;
            //request.contentType = ""

            var loader = new URLLoader();

            // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoaderDataFormat.html
            //loader.dataFormat = URLLoaderDataFormat.Binary;
            loader.dataFormat = "binary";
            // http://stackoverflow.com/questions/7816231/how-to-use-as3-to-load-binary-data-from-web-server

            loader.complete +=
                args =>
            {
                // If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object
                // containing the raw binary data.

                //                TypeError: Error #1034: Type Coercion failed: cannot convert ScriptCoreLib.Shared.BCLImplementation.System.Net::__DownloadStringCompletedEventArgs@5422ad9 to ScriptCoreLib.Shared.BCLImplementation.System.Net.__UploadValuesCompletedEventArgs.
                //at ScriptCoreLib.ActionScript.BCLImplementation.System.Net::__WebClient/_UploadValuesAsync_b__7_4ebbe596_06000fb2()[V:\web\ScriptCoreLib\ActionScript\BCLImplementation\System\Net\__WebClient.as:143]
                //at flash.events::EventDispatcher/dispatchEventFunction()
                //at flash.events::EventDispatcher/dispatchEvent()
                //at flash.net::URLLoader/redirectEvent()

                // TypeError: Error #1034: Type Coercion failed: cannot convert ScriptCoreLib.Shared.BCLImplementation.System.Net::__DownloadStringCompletedEventArgs@53686e9 to ScriptCoreLib.Shared.BCLImplementation.System.Net.__UploadValuesCompletedEventArgs.

                //throw new Exception(
                //    new { loader.data, loader.dataFormat, t = loader.data.GetType() }.ToString()
                //);

                var bytes  = (ByteArray)loader.data;
                var Result = (byte[])bytes.ToArray();

                //if (UploadValuesCompleted != null)
                //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                xx.SetResult(Result);
            };

            loader.ioError +=
                args =>
            {
                var e = new __UploadValuesCompletedEventArgs {
                    Error = new Exception("ioError")
                };
                //if (UploadValuesCompleted != null)
                //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                throw e.Error;
            };


            loader.securityError +=
                args =>
            {
                var e = new __UploadValuesCompletedEventArgs
                {
                    Error = new Exception(
                        "securityError " + new { args.errorID, args.text }
                        )
                };

                //if (UploadValuesCompleted != null)
                //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                throw e.Error;
            };

            loader.load(request);

            return(xx.Task);
        }
Ejemplo n.º 21
0
        public MySprite1()
        {
            // http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html


            InternalLoadTargetContent = TargetContent =>
            {
                this.OrphanizeChildren();

                // read more: http://www.senocular.com/flash/tutorials/contentdomains/
                Security.allowDomain("*");
                Security.allowInsecureDomain("*");
                //Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");

                // http://code.google.com/apis/youtube/flash_api_reference.html
                // http://code.google.com/p/gdata-samples/source/browse/trunk/ytplayer/actionscript3/com/google/youtube/examples/AS3Player.as

                var ldr    = new Loader();
                var urlReq = new URLRequest(TargetContent);

                var ctx_app = ApplicationDomain.currentDomain;
                var ctx_sec = SecurityDomain.currentDomain;

                if (TargetContent.StartsWith("http://www.youtube.com/"))
                {
                    // http://www.youtube.com/crossdomain.xml
                    ctx_app = null;
                    ctx_sec = null;

                    // http://www.zedia.net/2010/using-the-actionscript-3-youtube-api/

                    DoplayVideo = delegate
                    {
                        ldr.content.playVideo();
                    };


                    DoloadVideoById = (id, s, q) =>
                    {
                        ldr.content.loadVideoById(id, s, q);
                    };

                    Action <Event> onReady = e =>
                    {
                        if (VideoPlayerReady != null)
                        {
                            VideoPlayerReady();
                        }

#if JSC_FEATURE_dynamic
                        dynamic player = ldr.content;

                        player.setSize(160, 120);
#endif
                        ldr.content.setSize(160, 120);
                    };

                    ldr.contentLoaderInfo.init +=
                        delegate
                    {
                        ldr.content.addEventListener("onReady", onReady.ToFunction(), false, 0, false);
                    };
                }



                ldr.contentLoaderInfo.complete +=
                    delegate
                {
                    if (Ready != null)
                    {
                        Ready();
                    }
                };

                //ldr.mouseChildren = false;

                var ctx = new LoaderContext(true, ctx_app, ctx_sec);
                ldr.load(urlReq, ctx);

                var sprite2 = new Sprite
                {
                    z = 0.001
                }.AttachTo(this);


                sprite2.graphics.drawRect(0, 0, 100, 100);

                var t = new Timer(1000 / 60);

                t.timer +=
                    delegate
                {
                    var x = sprite2.x;
                    var y = sprite2.y;

                    sprite2.transform.matrix3D.appendTranslation(-x, -y, 0);
                    sprite2.transform.matrix3D.appendRotation(0.01, Vector3D.Y_AXIS);
                    sprite2.transform.matrix3D.appendRotation(0.02, Vector3D.X_AXIS);
                    sprite2.transform.matrix3D.appendTranslation(x, y, 0);
                };

                t.start();

                DoClean =
                    delegate
                {
                    ldr.content.GetChildren().Where(k => k.GetType().Name == "InfoPanel").ToArray().WithEach(
                        k => k.Orphanize()
                        );
                };

                ldr.AttachTo(sprite2);

                var Inspect = default(Action <DisplayObject, XElement>);

                Inspect = (Target, Journal) =>
                {
                    var SourceType = Target.GetType();

                    var n = new XElement(SourceType.Name);

                    n.Add(new XAttribute("Namespace", SourceType.Namespace));

                    SourceType.BaseType.With(
                        BaseType =>
                        n.Add(new XAttribute("BaseType", BaseType.FullName))
                        );


                    Journal.Add(n);

                    (Target as DisplayObjectContainer).With(
                        Container =>
                    {
                        for (int i = 0; i < Container.numChildren; i++)
                        {
                            Inspect(Container.getChildAt(i), n);
                        }
                    }
                        );
                };

                DoInspect =
                    delegate
                {
                    var doc = new XElement("Inspection");

                    // SecurityError: Error #2121: Security sandbox violation: Loader.content: http://localhost:26925/assets/LoadExternalFlashComponent.Application/LoadExternalFlashComponent.Components.MySprite1.swf cannot access http://sketch.odopod.com/flash/OdoSketch.swf?sketchURL=/sketches/231498.xml&userURL=/users/21416&bgURL=/images/bigbg.jpg&mode=embed. This may be worked around by calling Security.allowDomain.
                    //	at flash.display::Loader/get content()

                    try
                    {
                        Inspect(ldr.content, doc);
                    }
                    catch (Exception exc)
                    {
                        var n = new XElement("error", exc.Message);

                        doc.Add(n);
                    }

                    if (Inspecting != null)
                    {
                        Inspecting(doc);
                    }
                };
            };

            LoadTargetContent();
        }
Ejemplo n.º 22
0
 public static void NavigateTo(this URLRequest r, string window)
 {
 }
Ejemplo n.º 23
0
        public YouTubePlayer(
            string TargetContent = "http://www.youtube.com/apiplayer?version=3",
            int DefaultWidth     = 1280,
            int DefaultHeight    = 720,
            string DefaultVideo  = "Z__-3BbPq6g",

            string suggestedQuality = "hd720",


            Action yield_init = null
            )
        {
            var ldr = new Loader();

            this.Loader = ldr;
            var urlReq = new URLRequest(TargetContent);

            var ctx_app = ApplicationDomain.currentDomain;
            var ctx_sec = SecurityDomain.currentDomain;

            // http://www.youtube.com/crossdomain.xml
            ctx_app = null;
            ctx_sec = null;

            // http://www.zedia.net/2010/using-the-actionscript-3-youtube-api/

            bool once = false;

            #region onReady
            Action <Event> onReady = e =>
            {
                if (once)
                {
                    return;
                }

                once = true;


#if JSC_FEATURE_dynamic
                dynamic player = ldr.content;

                player.setSize(160, 120);
#endif
                ldr.content.setSize(DefaultWidth, DefaultHeight);

                pauseVideo = delegate
                {
                    ldr.content.pauseVideo();
                };

                loadVideoById = x =>
                {
                    CurrentVideoId = x;

                    ldr.content.loadVideoById(x, suggestedQuality: suggestedQuality);
                };

                loadVideoById(DefaultVideo);

                if (yield_init != null)
                {
                    yield_init();
                    yield_init = null;
                }
            };
            #endregion


            var PreviousCurrentState = YouTubePlayerState.unknown;
            var CurrentState         = YouTubePlayerState.unknown;

            DefaultScene = this["default", 0, 1000];
            var    CurrentScene     = DefaultScene;
            Action CurrentSceneDone = delegate { };

            #region onStateChange
            Action <Event> onStateChange = e =>
            {
                PreviousCurrentState = CurrentState;
                CurrentState         = e.get_data_as_YouTubePlayerState();

                if (PreviousCurrentState != CurrentState)
                {
                    if (CurrentState == YouTubePlayerState.playing)
                    {
                        // notify other scenes of delinking?

                        if (this.Playing != null)
                        {
                            this.Playing(SceneTranslate(CurrentScene));
                        }

                        this.ReferencedScenes.WithEach(
                            k =>
                        {
                            k.RaiseLinkDenotification();
                        }
                            );
                    }
                    else
                    {
                        if (this.NotPlaying != null)
                        {
                            this.NotPlaying(SceneTranslate(CurrentScene));
                        }
                    }

                    if (CurrentState == YouTubePlayerState.paused)
                    {
                        if (this.Paused != null)
                        {
                            this.Paused(SceneTranslate(CurrentScene));
                        }
                    }
                }
            };
            #endregion


            var TimeToPause = 0.4;

            var t = new Timer(1000 / 100);

            var PlaySceneCounter = 0;

            t.timer +=
                delegate
            {
                if (ldr.content == null)
                {
                    return;
                }

                if (CurrentState == YouTubePlayerState.playing)
                {
                    var time = ldr.content.getCurrentTime();

                    var time_index = (int)time;

                    var duration = ldr.content.getDuration();

                    var playall = CurrentScene.end > duration;

                    // flag4 = ((double0 < (double2 - 500)) == 0);
                    // 1 second is 1.0!! :)
                    var notending = time < (duration - 0.500);
                    //var xending = time >= (duration - 500);
                    var ending = !notending;

                    // ReferenceError: Error #1069: Property getDuration not found on flash.display.Loader and there is no default value.
                    var m = new { PlaySceneCounter, time, time_index, CurrentScene.end, duration, playall, ending }.ToString();

                    if (StatusToClients != null)
                    {
                        StatusToClients(m);
                    }

                    // phone activated

                    if (playall)
                    {
                        if (ending)
                        {
                            ldr.content.pauseVideo();
                            CurrentSceneDone();
                        }
                    }
                    else if (time >= (TimeToPause))
                    {
                        ldr.content.pauseVideo();
                        CurrentSceneDone();
                    }
                }
            };

            t.start();

            #region PlayScene
            this.PlayScene =
                (e, Done) =>
            {
                PlaySceneCounter++;

                //if (e.end == 0)
                //    e.end = ldr.content.getDuration() - 1000;

                CurrentScene     = e;
                CurrentSceneDone = Done;

                TimeToPause = e.end;

                ldr.content.seekTo(e.start);
                ldr.content.playVideo();
            };
            #endregion



            ldr.contentLoaderInfo.ioError +=
                delegate
            {
            };

            ldr.contentLoaderInfo.init +=
                delegate
            {
                ldr.content.addEventListener("onReady", onReady.ToFunction(), false, 0, false);
                ldr.content.addEventListener("onStateChange", onStateChange.ToFunction(), false, 0, false);
            };

            var ctx = new LoaderContext(true, ctx_app, ctx_sec);
            ldr.load(urlReq, ctx);


            this.Scenes = new SceneSequenzer {
                Owner = this
            };
        }