Пример #1
0
        void CreateTexture()
        {
            Size tsz = TextureSize();

            if (texture == null)
            {
                texture = TextureManager.Instance.GetByName(textureName);
            }
            if (texture != null)
            {
                log.InfoFormat("BrowserCodec[{0}]: Removing old texture \"{1}\"",
                               ID(), textureName);
                TextureManager.Instance.Remove(texture.Name);
                texture.Unload();
                texture = null;
                //d3dsurface = null;
            }
            texture = TextureManager.Instance.CreateManual(
                textureName,
                TextureType.TwoD,
                tsz.Width, tsz.Height,
                0, // no mip maps
                D3DHelper.ConvertEnum(D3D.Format.X8R8G8B8),
                TextureUsage.Dynamic);
            if (texture is D3DTexture)
            {
                D3D.Surface d3dsurface = ((texture as D3DTexture).DXTexture as D3D.Texture).GetSurfaceLevel(0);
                Graphics    g          = d3dsurface.GetGraphics();
                g.Clear(Color.Black);
                d3dsurface.ReleaseGraphics();
            }
        }
Пример #2
0
        void FrameStarted(object source, FrameEventArgs e)
        {
            try {
                if (texture == null ||
                    !(texture is D3DTexture) ||
                    ((texture as D3DTexture).DXTexture) == null ||
                    ((texture as D3DTexture).DXTexture as D3D.Texture) == null)
                {
                    return;
                }
                D3D.Surface d3dsurface = ((texture as D3DTexture).DXTexture as D3D.Texture).GetSurfaceLevel(0);
                if (ps == PLAY_STATE.BUFFERING)
                {
                    if (browser == null)
                    {
                        browser = new Browser();
                        browser.SetObjectForScripting(scriptingObj);
                        browser.SetSize(VideoSize());
                        CreateTexture();
                        bool ans = browser.Open(path);
                        if (ans == false)
                        {
                            ps      = PLAY_STATE.STOPPED;
                            browser = null;
                        }
                    }

                    if (browser.Loaded())
                    {
                        Play();
                    }
                    else
                    {
                        Graphics g = d3dsurface.GetGraphics();
                        string   text;
                        int      pct = browser.LoadPercent();
                        if ((pct == 100) || (pct == 0))
                        {
                            text = string.Format("Loading ({0}%)", pct);
                        }
                        else
                        {
                            text = string.Format("Loading ({0:d2}%)", pct);
                        }
                        switch ((count++ / 10) % 3)
                        {
                        case 0:
                            text += ".";
                            break;

                        case 1:
                            text += "..";
                            break;

                        case 2:
                            text += "...";
                            break;
                        }
                        g.Clear(Color.Black);
                        g.DrawString(text, loadingFont, Brushes.White, loadingPoint);
                        d3dsurface.ReleaseGraphics();
                    }
                }
                if (ps == PLAY_STATE.RUNNING)
                {
                    Graphics g = d3dsurface.GetGraphics();
                    browser.RenderTo(g);
                    d3dsurface.ReleaseGraphics();
                }
            }
            catch (Exception exc) {
                log.WarnFormat("BrowserMovie.FrameStarted exception: {0}, stack trace {1}",
                               exc.Message, exc.StackTrace);
            }
        }