I cannot tell where to put every single line in your app code, as this is just about programming after all, but here are some tips:
- in order to load the videos "on demand", instead of loading them in the onSurfaceCreated method, you'll want to load them when a target is detected
- you can determine "when" a target gets detected, by looking at the code that iterates over the list of TrackableResults returned by the Vuforia State at every frame (this is all in a "for" loop in the code); the relevant code is in the VideoPlaybackRenderer class
- in the same code, you can also detect when a target is no longer tracked (i.e. target has been lost), by comparing the list of currently active TrackableResults at the current frame, with the ones of the previous frame.
-based on the conditions above (target detected / target lost), you can establish when to load and when to unload the video associated to each Target; by the way, a convenient way of creating a mapping between each target and the associated video is to use a HashMap or HashTable, by which you can map the name of the target to the name of the video that is associated to that target.
Hope this helps.
Can you please check that the video plays natively i.e. on the device itself without any AR?
It could be a format issue.
N