播放和暂停,视频时间指示器未在 android 中显示我的 YouTube API

play and pause ,video time indicator not displaying my YouTube API in android

我正在使用 YouTube API。它工作正常,但播放和暂停以及视频时间指示器不显示。

下面是我的代码,有人能帮帮我吗?

public class PlayYouTube1st extends YouTubeBaseActivity implements
    YouTubePlayer.OnInitializedListener {

private static final int RECOVERY_DIALOG_REQUEST = 1;
String DEVELOPER_KEY = "AIzaSyjksmplqrQPzIDpWjdPeurjklmcJpbg";
// YouTube player view
private YouTubePlayerView youTubeView;
String youLink;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.youtube_main);
    Intent intent =getIntent();
    youLink=intent.getStringExtra("youtubeLink");
    youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
    Toast.makeText(PlayYouTube1st.this,
            youLink, Toast.LENGTH_LONG).show();

    // Initializing video player with developer key
    youTubeView.initialize(DEVELOPER_KEY, this);


}

@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
        YouTubeInitializationResult errorReason) {
    if (errorReason.isUserRecoverableError()) {
        errorReason.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show();
    } else {
        String errorMessage = String.format(
                getString(R.string.error_player), errorReason.toString());
        Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
    }
}

@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
        YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {

        // loadVideo() will auto play video
        // Use cueVideo() method, if you don't want to play it automatically
        player.loadVideo(youLink);

        // Hiding player controls
        player.setPlayerStyle(PlayerStyle.CHROMELESS);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RECOVERY_DIALOG_REQUEST) {
        // Retry initialization if user performed a recovery action
        getYouTubePlayerProvider().initialize(Config.DEVELOPER_KEY, this);
    }
}

private YouTubePlayer.Provider getYouTubePlayerProvider() {
    return (YouTubePlayerView) findViewById(R.id.youtube_view);
}
private YouTubePlayer.PlaybackEventListener playbackEventListener = new YouTubePlayer.PlaybackEventListener() {

    @Override
    public void onBuffering(boolean arg0) {
    }

    @Override
    public void onPaused() {
    }

    @Override
    public void onPlaying() {
    }

    @Override
    public void onSeekTo(int arg0) {
    }

    @Override
    public void onStopped() {
    }

};

private YouTubePlayer.PlayerStateChangeListener playerStateChangeListener = new YouTubePlayer.PlayerStateChangeListener() {

    @Override
    public void onAdStarted() {
    }

    @Override
    public void onError(YouTubePlayer.ErrorReason arg0) {
    }

    @Override
    public void onLoaded(String arg0) {
    }

    @Override
    public void onLoading() {
    }

    @Override
    public void onVideoEnded() {
    }

    @Override
    public void onVideoStarted() {
    }
};

}

将 YouTubePlayer 样式更改为:

player.setPlayerStyle(PlayerStyle.DEFAULT);

player.setPlayerStyle(PlayerStyle.MINIMAL);