我使用以下活动从我的应用程序启动 youtube 视频。活动启动时,会播放 youtube 视频。但是当我改变屏幕的方向时,视频并没有恢复,而是从头开始。这里有什么问题?
package com.example.blahblah;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.Toast;
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 YTPlayActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener {
static private String yt_sk;
static private final String DEVELOPER_KEY = "my-api-key";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.yt_player);
Bundle extras = getIntent().getExtras();
yt_sk = extras.getString("yt_sk");
YouTubePlayerView youTubeView = (YouTubePlayerView)
findViewById(R.id.youtube_view);
youTubeView.initialize(DEVELOPER_KEY, this);
}
@Override
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult error) {
Toast.makeText(this, "Oh no! "+error.toString(),
Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean wasRestored) {
player.loadVideo(yt_sk);
}
}