萤石文档
根据文档粘贴 、复制,页面听到声音,却一直再转圈。解决:
//设置加载需要显示的view mEZUIPlayer.setLoadingView(initProgressBar()); private View initProgressBar() { RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setBackgroundColor(Color.parseColor("#000000")); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); relativeLayout.setLayoutParams(lp); RelativeLayout.LayoutParams rlp=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT); rlp.addRule(RelativeLayout.CENTER_IN_PARENT);//addRule参数对应RelativeLayout XML布局的属性 ProgressBar mProgressBar = new ProgressBar(this); // mProgressBar.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress)); relativeLayout.addView(mProgressBar,rlp); return relativeLayout; }实现 SurfaceHolder.Callback:
@Override public void surfaceCreated(@NonNull SurfaceHolder holder) { if (player != null) { player.setSurfaceHold(holder); Log.d("surface","创建"); } mRealPlaySh = holder; player.startRealPlay(); } @Override public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) { if (player != null) { player.setSurfaceHold(holder); } mRealPlaySh = holder; } @Override public void surfaceDestroyed(@NonNull SurfaceHolder holder) { }实现 Handler.Callback:
@Override public boolean handleMessage(Message msg) { switch (msg.what) { case EZConstants.EZRealPlayConstants.MSG_REALPLAY_PLAY_SUCCESS: //播放成功 break; case EZConstants.EZRealPlayConstants.MSG_REALPLAY_PLAY_FAIL: //播放失败,得到失败信息 ErrorInfo errorinfo = (ErrorInfo) msg.obj; //得到播放失败错误码 int code = errorinfo.errorCode; //得到播放失败模块错误码 String codeStr = errorinfo.moduleCode; //得到播放失败描述 String description = errorinfo.description; //得到播放失败解决方方案 String sulution = errorinfo.sulution; break; case EZConstants.MSG_VIDEO_SIZE_CHANGED: //解析出视频画面分辨率回调 try { String temp = (String) msg.obj; String[] strings = temp.split(":"); int mVideoWidth = Integer.parseInt(strings[0]); int mVideoHeight = Integer.parseInt(strings[1]); //解析出视频分辨率 } catch (Exception e) { e.printStackTrace(); } break; default: break; } return false; }如果使用vue等打包,要把函数提升到 window 下;
window['handleTest'] = this.handleTest java 调用 mWebView.loadUrl("javascript:handleTest('dm')");