Correct way to implement callback in plugin


I’m trying to add a callback to a plugin that allows my app to play VR videos. In the plugin, there’s a file and a file.

Here’s what I have so far:

public class GoogleVRPlayer extends CordovaPlugin {
  public CallbackContext callback = null;
  public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
    if(action.equals("playVideo")) {
      String videoUrl = args.getString(0);
      Context context=this.cordova.getActivity().getApplicationContext();
      Intent intent=new Intent(context, VrVideoActivity.class);     
      intent.putExtra("videoUrl", videoUrl);

      callback = callbackContext;

    return true;



    public void onLoadError(String errorMessage) {
      // An error here is normally due to being unable to decode the video format.
        callback.error(); // --> doesn't work
        this.callback.error(); // --> doesn't work either
        Log.e(TAG, "Error loading video: " + errorMessage);

I’m getting this error:

error: cannot find symbol callback.error(); ^ symbol: variable callback

Any suggestions? I’m new to editing Cordova plugins…