感谢任何帮助。 我也想让视频可以下载,因为这些是公共视频。
public class VideoActivity extends Activity {
String url = " ";
private int REQ_PLAYER_CODE = 1;
private static String YT_KEY = "some keys";
我从另一个班级获取网址
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
Intent intent = getIntent();
// Intent in=getIntent();
Bundle bundle = getIntent().getExtras();
String url = bundle.getString("key");
Log.v("in mainactivity", "" + url);
assert url != null;
Intent videoIntent = null;
if (url != null) {
videoIntent = YouTubeStandalonePlayer.createVideoIntent(this, YT_KEY, url, 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();
}
}
}
}
根据用户的不同,我是否可以在任何模式下播放视频。
答案 0 :(得分:0)
将lightboxMode
更改为true
以纵向模式播放。
videoIntent = YouTubeStandalonePlayer.createVideoIntent(this, YT_KEY, url,0, true,true);