Looping Video Playback N-Times

Greetings,

I’m having a problem with playing video, and have searched high and low for a solution, but oddly, I cannot seem to find any other discussions about this specific issue.

I am building a cross-platform iOS/Android app for a client, which contains a number of videos of exercise sets, and I need the user to be able to choose a number of repeat plays for each video, from 1 to 10.

I’m currently playing the videos with media.playVideo, however, there doesn’t appear to be any way of specifying looped playback. I’ve tried native.newVideo as well, but again there doesn’t seem to be a property or parameter I can pass for the number of looped plays.

Additionally, as far as event listeners for video are concerned, it seems that there is only a ‘completion’ event and that there is no differentiation between the video completing playback on its own or being interrupted by the user.

Does anyone know if looping video is an option, or is it hard-coded that both of these playback methods only play once and then return a completion event to the listener (unless, of course, there is an error)?

If that is the case, then I’m thinking that my only recourse would be to do the following:

  1. Set up video playback.

  2. Get the total length of this video.

  3. Set a timer for that period, and set a repeat counter to zero.

  4. When the video player fires off a completion event, check to see if the timer is close to the length of the video, and if it is within a set range, increment the repeat counter and play the video again without returning the user back to the app. If the completion event fires but the timer is out of that range, then I can assume that the video was interrupted in some way, and thus the repeat loop gets canceled.

This, however, seems a) messy, and b) doesn’t account for the user having paused the playback of the video, for whatever reason, as that will result in the timer being out and could generate a repeat play cancellation in error.

If anyone has any thoughts on how best to resolve this situation, I’d love to hear them.

Many thanks, Niilo