我在 android 上制作了一个应用程序来使用 Youtube 的独立播放器观看 Youtube 视频(见这里)。一切都很好,但我无法为其添加停止活动。有没有办法完成这个活动?谢谢。
private int REQ_PLAYER_CODE = 1;
private static String YT_KEY = "AIzaSyAHBXzpIsBAGhKZwjvI0LoXDfc8hCqw64I";
private static String VIDEO_ID = "sjOfxnlGAF4"; // Your video id here
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.digersayfa);
Intent videoIntent = YouTubeStandalonePlayer.createVideoIntent(this, YT_KEY, VIDEO_ID, 0, true, false);
startActivityForResult(videoIntent, REQ_PLAYER_CODE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_PLAYER_CODE && resultCode != RESULT_OK) {
YouTubeInitializationResult errorReason = YouTubeStandalonePlayer.getReturnedInitializationResult(data);
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, 0).show();
} else {
String errorMessage = String.format("PLAYER ERROR!!", errorReason.toString());
Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show();
}
}
}