最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實現(xiàn)簡單畫中畫功能

 更新時間:2021年08月27日 10:33:33   作者:ckwccc  
這篇文章主要為大家詳細介紹了Android實現(xiàn)簡單畫中畫功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

Android 8.0推出了PictureInPicture(畫中畫功能),目前只有在8.0以上的系統(tǒng)上支持。對比IOS,IOS的Picture in Picture 模式是蘋果公司在 iOS 9 中加入的一項多任務(wù)功能。下面先看一下效果:

相信不少人在平時使用ios手機的app時,已經(jīng)體驗過了,很高興谷歌也推出了這項功能。

使用畫中畫模式注意點:

1.要使用畫中畫模式的Activity需要在清單文件中添加屬性:

android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:supportsPictureInPicture="true"

2.需要使用PictureInPictureParams類:

PictureInPictureParams.Builder mPictureInPictureParamsBuilder =
            new PictureInPictureParams.Builder();

3.添加待決定的意圖

ArrayList<RemoteAction> actions = new ArrayList<>();

 final PendingIntent intent =
                PendingIntent.getBroadcast(
                        MainActivity.this,
                        requestCode,
                        new Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, controlType),
                        0);
actions.add(new RemoteAction(icon, title, title, intent));

mPictureInPictureParamsBuilder.setActions(actions);

4.使用廣播接收各種意圖

private BroadcastReceiver mReceiver;

 mReceiver =
                    new BroadcastReceiver() {
                        @Override
                        public void onReceive(Context context, Intent intent) {
                            if (intent == null
                                    || !ACTION_MEDIA_CONTROL.equals(intent.getAction())) {
                                return;
                            }

                            // This is where we are called back from Picture-in-Picture action items.
                            //這就是我們從畫中畫模式的操作回調(diào)的地方
                            final int controlType = intent.getIntExtra(EXTRA_CONTROL_TYPE, 0);
                            switch (controlType) {
                                case CONTROL_TYPE_PLAY:
                                    mMovieView.play();
                                    break;
                                case CONTROL_TYPE_PAUSE:
                                    mMovieView.pause();
                                    break;
                            }
                        }
                    };
            registerReceiver(mReceiver, new IntentFilter(ACTION_MEDIA_CONTROL));

5.配合自定義的MediaPlayer使用:

private MovieView mMovieView;

//各種操作
mMovieView.showControls();
mMovieView.pause();
mMovieView.play();
mMovieView.hideControls();
mMovieView.setAdjustViewBounds(false);

通過廣播接收者接收各種操作意圖,對應(yīng)其操作

Demo地址:點擊查看

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

金华市| 贵州省| 太白县| 孝义市| 大名县| 新津县| 广德县| 庄浪县| 乐业县| 无棣县| 邵阳县| 浦县| 色达县| 巫山县| 怀仁县| 新和县| 兴山县| 耿马| 介休市| 武定县| 青浦区| 六盘水市| 西盟| 通州市| 周至县| 太湖县| 临沧市| 泽州县| 天峻县| 龙胜| 容城县| 繁峙县| 安义县| 龙里县| 桃园县| 梓潼县| 衡水市| 鹿泉市| 腾冲县| 潼南县| 额济纳旗|