android 实现播放视频画中画功能遇到的问题点

画中画功能
Android 8.0 Oreo(API Level 26)允许活动启动画中画 Picture-in-picture(PIP)模式,我就是采用官方api模式实现,还有一种实现方案采用的是window方式,我项目里采用的是第三方播放器感觉用window方式实现困难了些不好衔接。

具体实现很简单就几点 就是参照的官方文档

1在你的manifest配置文件配置你的播放类acitvity

 <activity android:name="VideoActivity"
  android:supportsPictureInPicture="true"
  android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
  android:launchMode="singleTask"

2在播放器控制栏添加的一个小窗播放按钮(参考爱奇艺) 点击按钮进入画中画模式

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        PictureInPictureParams.Builder pictureInPictureParamsBuilder = new PictureInPictureParams.Builder();
        mVideoWith = Player.getVideoWidth();
        mVideoHeight = Player.getVideoHeight();
        if (mVideoWith != 0 && mVideoHeight != 0) {
            Rational aspectRatio = new Rational(mVideoWith, mVideoHeight);
            pictureInPictureParamsBuilder.setAspectRatio(aspectRatio);
       
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值