ksvc / KSYMediaPlayer_Android

金山云Android播放SDK(KSYUN Live Streaming player SDK),支持RTMP HTTP-FLV HLS 协议(supporting RTMP HTTP-FLV HLS protocol),直播延时2-3秒(Living delay 2 or 3 seconds),supporting jitter control,software&hardware decode
http://v.ksyun.com/
Apache License 2.0
856 stars 247 forks source link

KSYTextureview 连接网络视频mp4,prepareAsync()方法有执行,加载的时候会堵塞UI主线程,求解 #281

Open moriliefeng opened 6 years ago

moriliefeng commented 6 years ago

private void loadVideo(String url) { if(mVideoView == null) return; mVideoView.setVisibility(View.VISIBLE); mVideoView.setKeepScreenOn(true); mVideoView.setOnCompletionListener(mOnCompletionListener); mVideoView.setOnPreparedListener(mOnPreparedListener); mVideoView.setOnInfoListener(mOnInfoListener); mVideoView.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener); mVideoView.setOnErrorListener(mOnErrorListener); mVideoView.setScreenOnWhilePlaying(true); mVideoView.setLooping(true); //设置播放参数

    if (KSYHardwareDecodeWhiteList.getInstance().getCurrentStatus() == KSYHardwareDecodeWhiteList.KSY_STATUS_OK) {
        if (KSYHardwareDecodeWhiteList.getInstance().supportHardwareDecodeH264()
                || KSYHardwareDecodeWhiteList.getInstance().supportHardwareDecodeH265())
            mVideoView.setDecodeMode(KSYMediaPlayer.KSYDecodeMode.KSY_DECODE_MODE_AUTO);
    }

    try {
        mVideoView.setDataSource(UriUtil.wrapPath(url));
    } catch (IOException e) {
        e.printStackTrace();
    }
    mVideoView.prepareAsync();
}

这个是执行加载视频的代码