Expanding VideoTextureProvider api
Hello!!
I have created a project starting from the Marker template, I placed a sprite as child of the Marker that is meant to play a video from a script on tap.
Every time the video is finished playing I swap the source of the video for a second one and back to the first one, then I wait for a new tap to play the source.
After playing the second video what I see is the last frame of the first video, instead of the first one. Is there a way to specify that the video is to start from the beginning?
I have tried doing a play() followed by a pause() after every swap and then just resuming the video but I get an error.
The script is pretty straightforward.
//@input Asset.Texture ExplodeOpen
//@input Asset.Texture ExplodeClose
script.movieSprite.getMaterial(0).getPass(0).baseTex.control.play(1);
script.movieSprite.getMaterial(0).getPass(0).baseTex.control.setOnFinish(swapVideoClip)
function swapVideoClip()
{
if(script.movieSprite.getMaterial(0).getPass(0).baseTex === "AR ExplodeOpen_3")
script.movieSprite.getMaterial(0).getPass(0).baseTex = script.ExplodeClose
else
script.movieSprite.getMaterial(0).getPass(0).baseTex = script.ExplodeOpen
}
If there is no way around this it would be a nice feature to add something like with 2D animations,
playFromFrame(Number frameIndex, Number loops)
: void
https://lensstudio.snapchat.com/api/classes/AnimatedTextureFileProvider/
Best Regards!
Hi Aitor!
Sounds pretty cool :)
For the error: make sure you are checking the video status before calling a function on it--https://lensstudio.snapchat.com/api/classes/VideoStatus/ . For example it wouldn't be a good idea to tell the video to stop if the video is already stopped. This might be why you're getting an error.
I'll definitely let the development team about this feature request.
Can't wait to see your final lens!
Cheers,
Jon