A Flutter plugin that integrates Tencent's Video Animation Player (VAP) technology for high-performance video animations with dynamic content replacement. Supports multiple simultaneous animations through individual VAPView widgets.
- High-Performance Playback: Hardware-accelerated video animation rendering
- Flexible Controls: Loop options, scale types, audio control, lifecycle management
- Dynamic Content: Text and image injection (Base64, files, assets, URLs)
- Event System: Complete lifecycle and error handling callbacks
- Multiple Instances: Run concurrent animations with independent widgets
Android (android/app/build.gradle):
android {
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
}
}iOS (ios/Podfile):
platform :ios, '11.0'// Basic VAP animation
VapView(
scaleType: ScaleType.fitCenter,
repeat: -1,
onViewCreated: (controller) {
controller.setAnimListener(
onVideoStart: () => print('Started'),
onVideoComplete: () => print('Completed'),
onFailed: (code, type, msg) => print('Error: $code'),
);
controller.playAsset('animations/sample.mp4');
},
)
// With dynamic content
VapView(
vapTagContents: {
'username': TextContent('John Doe'),
'avatar': ImageURLContent('https://example.com/avatar.jpg'),
'badge': ImageAssetContent('assets/images/badge.png'),
},
onViewCreated: (controller) => controller.playAsset('animations/profile.mp4'),
)scaleType: How video scales (fitCenter,centerCrop,fitXY)repeat: Loop count (0=once, -1=infinite, 1=2times, 2=3times and so on)mute: Audio enabled/disabledvapTagContents: Initial dynamic contentonViewCreated: Controller callback
// Playback
await controller.playFile('/path/to/file.mp4');
await controller.playAsset('assets/anim.mp4');
await controller.stop();
await controller.setLoop(-1);
// Content Management
await controller.setVapTagContent('tag', TextContent('text'));
await controller.setVapTagContents({'tag1': content1, 'tag2': content2});
VAPContent? content = await controller.getVapTagContent('tag');
await controller.clearVapTagContents();
// Events
controller.setAnimListener(
onVideoStart: () {},
onVideoComplete: () {},
onFailed: (code, type, msg) {},
);TextContent('text')- Dynamic textImageBase64Content('base64...')- Base64 imagesImageFileContent('/path/file.jpg')- Local filesImageAssetContent('assets/img.png')- Flutter assetsImageURLContent('https://url.jpg')- Remote images
Common error codes:
-1: File not found-2: Playback error-1001: Invalid video data-1002: Decoder malfunction-1006: File too large
controller.setAnimListener(
onFailed: (code, type, message) {
switch (code) {
case -1: /* Handle file not found */; break;
case -1001: /* Handle corrupted data */; break;
default: print('Error $code: $message');
}
},
);- Memory Management: Always dispose controllers in
dispose() - Batch Updates: Use
setVapTagContents()for multiple content updates - Error Handling: Wrap playback calls in try-catch blocks
- Performance: Use appropriate scale types and avoid unnecessary infinite loops
- Animation not playing: Check VAP file exists, verify asset registration
- Memory issues: Dispose controllers, limit concurrent animations
- Content not updating: Verify tag names, set content before playback
- iOS build issues: Ensure iOS 11.0+, run
pod install
We welcome contributions to improve this plugin! Please feel free to:
- Report bugs and issues
- Suggest new features
- Submit pull requests
- Improve documentation
This Flutter plugin is built upon the excellent work of Tencent's VAP project:
- Original VAP Project: https://github.com/Tencent/vap
- License: MIT License
- Tencent VAP Team: For creating the foundational VAP technology
We extend our gratitude to the Tencent team for developing and open-sourcing the VAP framework, which makes high-performance video animations accessible to developers worldwide.
This project is licensed under the MIT License - see the LICENSE file for details.
The original Tencent VAP project is also licensed under the MIT License.