Scaleform Play a live video in texture?

181 Views Asked by At

I would like to know if it's possible to play a live video, from a webcam for example, in a texture in Scaleform?
Thanks.

1

There are 1 best solutions below

2
On

To do this, you just need to replace the appropriate image inside the swf, with one that wraps the texture that contains your video.

You will need to have your video texture in a texture from the graphics API you are using (for example, in DirectX 11, you'd need an ID3D11Texture2D). You can create a Scaleform wrapper image around this, using the TextureImage class. You then need to find the resource within the SWF which you want to replace, and set the wrapper image as its image. Finally, you need to call ForceImageUpdate on the GFx::Movie, to propagate the texture change.

ID3D11Texture2D* videoTexture = ...;
Ptr<GFx::Movie> pMovie = ...;
Ptr<D3D1x::TextureManager> pmanager = ...;
Ptr<Render::Texture> scaleformTexture = *pmanager->CreateTexture( videoTexture, ImageSize(width, height));
Ptr<TextureImage> scaleformImage = * SF_NEW TextureImage(Image_R8G8B8, scaleformTexture->GetSize(), 0, scaleformTexture);
ImageResource* pimageRes = (ImageResource*)pMovie->GetMovieDef()->GetResource("name_of_resource");
pimageRes->SetImage(scaleformImage);
pMovie->ForceUpdateImages();

When you update the underlying ID3D11Texture2D (eg. with a new frame), the image in the Scaleform movie will also change. An example of how to do all this is shown within the TextureInSWF sample, which is a little more thorough than this code. If you have the XBoxOne SDK, there is also a KinectInSWF sample, which shows how to do this with the Kinect Camera (eg. a live video camera).