I'm trying to use the new api youtube. I followed the examples provided, but I get the error: ERROR_CONNECTING_TO_SERVICE
The "API key" that I'm using is correct (since it works correctly in the google demos).
Imports:
import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView;
Classe definition:
public class Track extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
private YouTubePlayerView ytpv;
private YouTubePlayer ytp;
public void onCreate(Bundle savedInstanceState) {
...
ytpv = (YouTubePlayerView) findViewById(R.id.youtube_view);
ytpv.initialize("my_api_key_correctly_created", this);
}
public void onInitializationFailure(Provider arg0, YouTubeInitializationResult arg1) {
Toast.makeText(this, "Initialization Fail" + arg1.toString(), Toast.LENGTH_LONG).show();
}
public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1, boolean arg2) {
ytp = arg1;
Toast.makeText(this, "Initialization Success", Toast.LENGTH_LONG).show();
if(ytp !=null)
{
ytp.loadVideo("ZvvgDC_MNqI");
}
}
}
What am I doing wrong? Thank you, and sorry my english:)