Closed keval5531 closed 9 years ago
I have solved the issue, it was a silly me missing out the import
and fixes for newer libraries of Cordova. This code is good, it builds, now the Intent won't start; dunno what's the issue.
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubeStandalonePlayer;
public class YoutubePlugin extends CordovaPlugin {
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
String url = args.getString(0);
this.openVideo(url);
return true;
}
private void openVideo(String videoid) {
Intent youtubeIntent = YouTubeStandalonePlayer.createVideoIntent((Activity) this.cordova, "myid", videoid);
this.cordova.startActivityForResult(this, youtubeIntent, 0);
}
}
I am using Ionicframework with Cordova v5.0.0. Since there have been changes with Cordova, the import changed:
from:
to
But I still am facing errors. I would be grateful if I get a fix for this.