RemcoB00 / cordova-phonegap_youtube_player_api_android

YouTube Android Player API plugin for Cordova & Phonegap.
15 stars 14 forks source link

Unable to build for Android #1

Closed keval5531 closed 9 years ago

keval5531 commented 9 years ago

I am using Ionicframework with Cordova v5.0.0. Since there have been changes with Cordova, the import changed:

from:

 import org.apache.cordova.api.CordovaPlugin;
 import org.apache.cordova.api.PluginResult;

to

import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;

But I still am facing errors. I would be grateful if I get a fix for this.

C:\Users\Keval\Desktop\Ionic\YTest\platforms\android\src\com\remcob00\plugins\youtube\YouTube.java:25: method does not override or implement a method from a supertype                                                                                                                
@Override                                                                                                                              ^                                                                                                                              
C:\Users\Keval\Desktop\Ionic\YTest\platforms\android\src\com\remcob00\plugins\youtube\YouTube.java:38: cannot find symbol              
symbol  : variable cordova                                                                                                             
location: class com.remcob00.plugins.youtube.YouTube
Intent youtubeIntent = YouTubeStandalonePlayer.createVideoIntent((Activity) this.cordova, "myid", videoid);
C:\Users\Keval\Desktop\Ionic\YTest\platforms\android\src\com\remcob00\plugins\youtube\YouTube.java:39: cannot find symbol              
symbol  : variable cordova                                                                                                             
location: class com.remcob00.plugins.youtube.YouTube                                                                                                   
this.cordova.startActivityForResult(this, youtubeIntent, 0);                                                                               ^                                                                                                                   
FAILED                                                                                                                                                                                                                                                                       
BUILD FAILED                                                                                                                           
keval5531 commented 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);
    }

}