为什么YouTube视频在横向模式下播放而不是(垂直)纵向模式?

时间:2016-03-18 06:59:39

标签: android youtube

感谢任何帮助。 我也想让视频可以下载,因为这些是公共视频。

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();
        }
    }
}

 }

根据用户的不同,我是否可以在任何模式下播放视频。

1 个答案:

答案 0 :(得分:0)

lightboxMode更改为true以纵向模式播放。

videoIntent = YouTubeStandalonePlayer.createVideoIntent(this, YT_KEY, url,0, true,true);