我想在Android应用中播放https视频

时间:2016-12-10 20:13:37

标签: android https youtube android-videoview vitamio

我想在Android中播放来自安全网址(https)的视频。 我使用过vitamio播放器,但这个播放器只播放http连接而不是https。 这是我的代码。

Vitamio.isInitialized(getApplicationContext());

    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.tvplay);
    Log.d("url=", getIntent().getStringExtra("url"));
    url = getIntent().getStringExtra("url");
    init();

}

public void init() {
    load = (ProgressBar) this.findViewById(R.id.load);
    empty = (TextView) this.findViewById(R.id.empty);
    mVideoView = (VideoView) this.findViewById(R.id.surface_view);
    mVideoView.setMediaController(new MediaController(this));
    mVideoView.setOnCompletionListener(this);
    mVideoView.setOnPreparedListener(this);
    mVideoView.setOnErrorListener(this);
    Uri videoUri = Uri.parse(url);
    mVideoView.setVideoURI(videoUri);
    mVideoView.requestFocus();
    loading();
}

private void loading() {
    load.setVisibility(View.VISIBLE);
    empty.setVisibility(View.GONE);
}

private void loadComplete(MediaPlayer arg0) {
    load.setVisibility(View.GONE);
    // vv.setVisibility(View.VISIBLE);
    empty.setVisibility(View.GONE);
    mVideoView.start();
    mVideoView.resume();
}

private void error(String msg) {
    load.setVisibility(View.GONE);
    mVideoView.setVisibility(View.GONE);
    empty.setVisibility(View.VISIBLE);
    if (msg != null)
        empty.setText(msg);
}

请帮助我。 感谢

1 个答案:

答案 0 :(得分:0)

Vitamio不直接支持https。您可能需要使用OpenSSL重新编译库。或使用其他SSL支持的开源播放器