我正在尝试使用新的 api youtube。我按照提供的示例进行操作,但出现错误:ERROR_CONNECTING_TO_SERVICE
我使用的“API 密钥”是正确的(因为它在谷歌演示中正常工作)。
进口:
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;
类定义:
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");
}
}
}
我究竟做错了什么?谢谢,对不起我的英语:)