hxCodec
hxCodec copied to clipboard
Add video caching
Video caching is needed so it doesn't lag when creating the video
Video caching was made but not pushed. Very experimental tho.
Video caching is needed so it doesn't lag when creating the video
Actually, If you make a timer for 1 second before the video plays, it doesnt lag. Maybe a bit for really lowend but it works great just adding a FlxTimer for 1 sec before the video plays
Video caching was made but not pushed. Very experimental tho.
I know its experimental but how exactly would you do the video caching
Its a lazy method.
Its a lazy method.
adding the timer or the video caching? the timer makes the videos load great. The FlxSprite lags out on my PC tho but for normal cutscenes just adding a small timer makes the perf a lot better
I made this function that would work. You use it right before super.create(), and I currently use it in CoolUtil.hx for Lunar Engine:
Precache Video Function
public static var loadingVideos:Array<String> = [];
public static var loadedVideos:Array<String> = [];
public static function precacheVideo(name:String):Void {
#if VIDEOS_ALLOWED
if(FileSystem.exists(Paths.video(name))) {
if(!loadedVideos.contains(name)) {
loadingVideos.push(name);
var cache:VideoHandler = new VideoHandler();
cache.canUseSound = false;
cache.playVideo(Paths.video(name));
cache.onOpening = function() {
cache.stop();
cache.dispose();
loadedVideos.push(name);
loadingVideos.remove(name);
}
FlxG.log.add('Video file has been cached: ' + name);
} else {
FlxG.log.add('Video file has already been cached: ' + name);
}
} else {
FlxG.log.warn('Couldnt find video file: ' + name);
}
#else
FlxG.log.warn('Platform not supported!');
#end
}
noted. Thanks bro