这是日志:
由于:java.lang.NullPointerException:尝试调用接口 方法“无效” com.google.android.youtube.player.YouTubePlayer.cueVideo(java.lang.String)' 在空对象引用上
我不知道为什么会有这个错误?
public class StudyActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
YouTubePlayerView youTubePlayerView;
YouTubePlayer player;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_study);
youTubePlayerView.initialize(KEY.YOUTUBE_API_KEY,this);
player.cueVideo("GyrH6xiFiT0");
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
player = youTubePlayer;
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
Toast.makeText(this, "Error!", Toast.LENGTH_SHORT).show();
}
}