"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Adding number of videos and changing NUM_VIDEO_TARGETS

Hi there,

I am very new to the world of AR using Vuforia and I have been tasked with modifying an exiting project which was derived from the VideoPlayback example to add new videos.

There are 3 image triggers created using Target Manager and all 3 are detected in the app fine (i.e. they add the overlay ready to play).

I have searched online for what to do and have modified the following:

ARParentViewController.mm

switch (i) {
    case 0:
        filename = @"video1.m4v";
        break;
    case 1:
        filename = @"video2.m4v";
        break;
    case 2:
        filename = @"video3.m4v";
        break;
    default:
        filename = @"videodefault.m4v";
        break;
}

EAGLView.h


#define NUM_VIDEO_TARGETS 3

EAGLView.mm

// VideoPlayerHelper to use for current target
int playerIndex = 0;    // stones
        
if (strcmp(imageTarget.getName(), "TriggerOne") == 0)
{
    playerIndex = 0;
}
else if (strcmp(imageTarget.getName(), "TriggerTwo") == 0)
{
    playerIndex = 1;
}
else if (strcmp(imageTarget.getName(), "TriggerThree") == 0)
{
    playerIndex = 2;
}

 

When running the code it crashes until  NUM_VIDEO_TARGETS is set to 2. Then when doing this and the app actually loads but when selecting to play the third video (videothree.m4v) the app crashes in the TouchesEnded method. This crash happens when tapping the screen anywhere unless tapped on the play button overlay.

Can anybody help get me on the right track? The tapping issue looks seperate to the adding more videos to the app.

This particular sample was hardcoded to show exactly two videos, which is why when you change NUM_VIDEO_TARGETS it will crash.

However in this thread I discuss how to get around this problem:

https://developer.vuforia.com/forum/ios/integrating-videoplayer-sample-existing-app