Ejemplo n.º 1
0
        public static AvalonSoundChannel ToSound(this string asset)
        {
            var a = new IHTMLAudio {
                src = asset, autobuffer = true
            };


            a.AttachToDocument();
            //a.style.display = IStyle.DisplayEnum.none;

            // we can now use HTML5 audio element
            var x = new AvalonSoundChannel
            {
                Start =
                    delegate
                {
                    a.play();
                },

                Stop =
                    delegate
                {
                    a.pause();
                }
            };

            a.onended +=
                delegate
            {
                x.RaisePlaybackComplete();
            };


            return(x);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is a javascript application.
        /// </summary>
        /// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
        public OtherApplication(IOtherPage page)
        {
            var AudioLinks = this.AudioLinks.ToArray();

            Native.Document.body.Clear();

            new IHTMLButton {
                innerText = "open Default page"
            }.AttachToDocument().With(
                btn =>
            {
                new HTML.Images.FromAssets.jsc().AttachTo(btn);

                btn.onclick +=
                    delegate
                {
                    new IHTMLIFrame
                    {
                        src = "/"
                    }.AttachToDocument();

                    //Native.Window.open("/", "_self");
                };
            }
                );

            AudioLinks.WithEach(
                a =>
            {
                IHTMLAudio audio = null;

                new IHTMLButton {
                    innerText = a.innerText
                }.AttachToDocument().With(
                    btn =>
                {
                    btn.style.display = IStyle.DisplayEnum.block;

                    btn.onclick +=
                        delegate
                    {
                        if (audio == null)
                        {
                            audio = new IHTMLAudio {
                                src = a.href
                            }.AttachToDocument();
                            audio.play();
                        }
                        else
                        {
                            if (audio.paused)
                            {
                                audio.play();
                            }
                            else
                            {
                                audio.pause();
                            }
                        }
                    };
                }
                    );
            }
                );


            // XMLHttpRequest cannot load http://192.168.1.100:16304/xml?WebMethod=06000001. Origin http://www.webgljobs.com is not allowed by Access-Control-Allow-Origin.
            // Send data from JavaScript to the server tier
            //service.WebMethod2(
            //    @"other",
            //    value => value.ToDocumentTitle()
            //);
        }