Start a new topic
Solved

Are we able to detect when a video has finished playing?

I'm looking to move to another screen when a AR launched video has finished playing. Is there a way we can do this in the iOS Javascript SDK?


The way below worked in the end. Thanks for the help!


var convertPrivateAugmentationVideo = function (video, signal) {

            var onFinishedPlayingFn = function () {

              // My code here 

            };

            var options = generateDrawable2DOptions(video);

            options.isTransparent = video.properties.videoMode == "overlayAlpha";

            options.onFinishedPlaying = onFinishedPlayingFn;

[...]

}

Good morning Morgan,



that should certainly work. Would you mind trying to set the callback property when initializing the VideoDrawable instead?


var videoDrawable = new AR.VideoDrawable(..., {

    [...],

    onFinishedPlaying: function() {

        // your code here

    }

});



- Daniel

Thanks Daniel, good to know. Where would I specify the code to run? I've tried the following in the template.js file within  var convertPrivateAugmentationVideo and it causes the video to not play.       


videoDrawable.onFinishedPlaying = function () {

var = "do all this";

            };


Good morning James,



we offer the onFinishedPlaying event for that. You should get notified via this callback when an AR.VideoDrawable finishes playing, hence the name.



- Daniel

Any ideas on this one?

Login or Signup to post a comment