I noticed that every time I play the same video twice with Ursina Entity video player I get a desynch between the video and audio because the video does not start at the first frame but at a later time, and it loops over as it ends too early.
I found a similar post where it is described how to extract audio from mp4 video files and synch audio with video here but I'd like to keep the audio and video files separate.
I suppose it is a problem of unloading the buffer in Panda3D, I attempted several texture/buffer cleaning functions without any success.
I also tried adding several delays to give the engine the time to load audio and videos properly, but I suspect that it is a problem of anticipation rather than delay.
Here's my code:
#load and playing audio
audio_entity = Audio('audio/' + audio_file+ '.wav', loop=False, autoplay=True)
trial_length = audio_entity.length
destroy(audio_entity, delay=trial_length)
#load and play video
video_entity = Entity(model='cube', texture='video/'+video_file + '.mp4', scale_x=0.8, scale_y=0.8, alpha=0, parent=camera.ui) # set video texture
video_entity.fade_in(value=1, duration=0.3)
video_entity.fade_out(value=0, duration=0.3, delay=trial_length)
destroy(video_entity, delay=trial_length)