updateTexture method
Release current texture then create a new one for current media, and update textureId.
Texture will be created when media is loaded and mediaInfo.video
is not empty.
If both width
and height
are null, texture size is video frame size, otherwise is requested size.
Implementation
Future<int> updateTexture(
{int? width, int? height, bool? tunnel, bool? fit}) async {
if (_texId >= 0) {
textureId.value = null;
await FvpPlatform.instance.releaseTexture(nativeHandle, _texId);
_texId = -1;
}
if (width == null && height == null) {
// original size
final size = await _videoSize.future;
if (size == null) {
return -1;
}
_texId = await FvpPlatform.instance.createTexture(nativeHandle,
size.width.toInt(), size.height.toInt(), tunnel ?? false);
textureId.value = _texId;
return _texId;
}
if (width != null && height != null && width > 0 && height > 0) {
_texId = await FvpPlatform.instance
.createTexture(nativeHandle, width, height, tunnel ?? false);
textureId.value = _texId;
return _texId;
}
// release texture if width or height <= 0
return _texId;
}