android使用阿里云推流播放器记录

android使用阿里云推流播放器记录:

    在这里扯一句,如何删除csdn自己上传的资源:(参考:https://blog.csdn.net/qq_38122230/article/details/79894666
    

1、阿里云视频播放器sdk地址:https://help.aliyun.com/document_detail/61910.html?spm=a2c4g.11186623.6.810.4ed6533cEJ431r

                
2、播放实现参考:

    https://download.csdn.net/download/u010326875/10832938  集成arr基础播放功能的实现 

    https://download.csdn.net/download/hycfire/9884170  集成jar+so的demo实现

    https://blog.csdn.net/nibinusm22b/article/details/59611109   android 阿里云OSS文件上传             
            
    https://www.jianshu.com/p/63f6d5503513   参考定义SurfaceView

    https://github.com/totond/GestureTest   视频手势监听demo


3、阿里提供的状态方法使用(调节亮度、声音、或静音)
    https://help.aliyun.com/document_detail/61908.html?spm=a2c4g.11186623.6.812.4a3b659cU0qNW5
    
    
4、自定义RelativeLayout时,获取当前view的高度:

    onWindowFocusChanged方法中获取: 
    onWindowFocusChanged方法执行时代表View已经初始化完毕了,宽度和高度已经测量完毕并且最终确认好了,这时我们可以放心的在这里去获取View 的宽度和高度。
         @Override
        public void onWindowFocusChanged(boolean hasWindowFocus) {
            super.onWindowFocusChanged(hasWindowFocus);
            if(hasWindowFocus){
                int width = view.getMeasuredWidth();
                int height = view.getMeasuredHeight();
            }
        }

5、获取状态栏的高度:

    //状态栏高度:
    int statusBarHeight = 0;
    int resourceId = this.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = this.getResources().getDimensionPixelSize(resourceId);
    }
    
    //获取屏幕高度:
    Resources resources = this.getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    int height = dm.heightPixels;
    
6、自己设置视频屏幕的宽高:

        /**
     * 动态设置播放器的高度
     * @param screenHeight int
     */
    public void setWindowWidthHeight(int screenHeight,int orientation){
        int statusBarHeight = 0;
        int resourceId = this.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            statusBarHeight = this.getResources().getDimensionPixelSize(resourceId);
        }
        RelativeLayout.LayoutParams linearParams =(RelativeLayout.LayoutParams)getLayoutParams();
        if(orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
            linearParams.height = screenHeight+statusBarHeight;// 控件的宽强制设成30
            Log.e("mPlayer","LANDSCAPE height == "+linearParams.height);
        }else{
            linearParams.height = screenHeight-statusBarHeight;// 控件的宽强制设成30
            Log.e("mPlayer","PROTRAIT height == "+linearParams.height);
        }
        setLayoutParams(linearParams); //使设置好的布局参数应用到控件
    }
    
7、解决在android端按home键返回后,只有声音没有画面的问题:(本身阿里SDK播放器,就要求要有SurfaceView和对应的SurfaceHolder.Callback)

    mSurfaceView.getHolder().addCallback( new SurfaceCallback());
    

    /**
     * SurfaceCallback,SurfaceView回调
     */
    private class SurfaceCallback implements SurfaceHolder.Callback{
        //创建
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            //默认加载完成即播放
            if(holder!=null){
                holder.setKeepScreenOn(true);
            }
            if(mPlayer!=null){
                mPlayer.setVideoSurface(holder.getSurface());
            }
        }
        //改变
        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
            if(mPlayer!=null) {
                mPlayer.setSurfaceChanged();
            }
        }
        //销毁
        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {}
    }

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

漠天515

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值