2016-03-05 20 views
1

我在Away3D中运行VideoTexture,通常运行良好。我一直在试图减少视频之间的黑色差距,并试图让它们排得很好,但是我的尝试导致视频有时降级到移动设备上的软件渲染,特别是在它首次启动时。VideoTexture降级到软件在空中渲染

我使用Away3D与Starling和共享stage3DProxy。

下面是如何设置的视频了

  sphereGeometry = new SphereGeometry(5000, 64, 48); 
      panoTexture2DBase = new NativeVideoTexture(Model.config.getAssetUrl(Model.currentScene.video), true, true); 

      panoTexture2DBase.addEventListener(NativeVideoTexture.VIDEO_START,function(e:Event =null){setTimeout(onVideoStart,1000)}); 
      panoTextureMaterial = new TextureMaterial(panoTexture2DBase, false, false, false); 

      panoVideoMesh = new Mesh(sphereGeometry, panoTextureMaterial); 
      panoVideoMesh.scaleX *= -1; 

      panoVideoMesh.rotate(Vector3D.Y_AXIS,-90); 

      scene.addChild(panoVideoMesh); 
      view.render(); 

      panoTexture2DBase.player.pause(); 

我使用的Away3D NativeVideoTexture加载的NetStream。后续的视频通常很好,并且硬件加速。它只是第一个总是降级的人。

我NativeVideoTexture类

override protected function createTexture(context:Context3D):TextureBase 
    { 
     try 
     { 
      trace("Context3D.supportsVideoTexture", Context3D.supportsVideoTexture) 

      if (!Context3D.supportsVideoTexture) 
      { 
       throw new Error("flash.display3D.textures.VideoTexture not supported"); 
       return null; 
      } 

      texture = context.createVideoTexture(); 
      texture.attachNetStream(_player.ns); 

      _player.ns.addEventListener(NetStatusEvent.NET_STATUS, netstat); 
      _player.ns.seek(1); 
      texture.addEventListener(Event.TEXTURE_READY, onTextureReady); 
      texture.addEventListener(VideoTextureEvent.RENDER_STATE, onRenderState); 

      if (_autoPlay) _player.play(); 

     } 
     catch (e:Error) 
     { 
      trace(e, e.getStackTrace()); 
     } 

     return texture; 
    } 

    private function onMetaData(metaData:Object):void 
    { 
     duration = metaData.duration; 

    } 

    private function onTextureReady(e:Event):void 
    { 
    // trace("NativeVideoTexture.onTextureReady()"); 
     if(_player.duration) 
      if(_player.ns.time > _player.duration - 1){ 
       _player.pause(); 
       dispatchEvent(new Event(VIDEO_STOP)); 
       _player.seek(0); 
      } 
      else if(_player.ns.time > 0.01 && waitingForBuffer){ 
       dispatchEvent(new Event(VIDEO_START)); 
       waitingForBuffer = false; 
      } 

    } 




    private function onRenderState(e:VideoTextureEvent):void 
    { 
     trace(e.status); 
     if (e.status == VideoStatus.SOFTWARE) 
     { 
      trace("Indicates software video decoding works.") 
     } 
     if (e.status == VideoStatus.ACCELERATED) 
     { 
      trace("Indicates hardware-accelerated (GPU) video decoding works.") 
     } 
     if (e.status == VideoStatus.UNAVAILABLE) 
     { 
      trace("Indicates Video decoder is not available.") 
     } 
    } 

谁能帮我明白为什么第一视频软件总是呈现?

编辑:我已经取得了一些进展

有时,它开始在GPU模式下,有时软件。有什么会导致这种情况的?

回答

0

哈克,但它的作品。

如果要进行软件渲染,请停止并重新启动视频,直到它在GPU上呈现。似乎只需要几次。