• <strike id="fdgpu"><input id="fdgpu"></input></strike>
    <label id="fdgpu"></label>
    <s id="fdgpu"><code id="fdgpu"></code></s>

  • <label id="fdgpu"></label>
  • <span id="fdgpu"><u id="fdgpu"></u></span>

    <s id="fdgpu"><sub id="fdgpu"></sub></s>
    您當前的位置是:  首頁(yè) > 新聞 > 國內 >
     首頁(yè) > 新聞 > 國內 >

    Android 8.0 中如何實(shí)現視頻通話(huà)的畫(huà)中畫(huà)模式

    2017-12-11 13:53:00   作者:   來(lái)源:CTI論壇   評論:0  點(diǎn)擊:


      Android 8.0 當中允許 Activiy 以畫(huà)中畫(huà)模式展現。這是一種多窗口模式的改進(jìn)加強,在視頻類(lèi)應用中用處非常大,有了這種模式,就可以在視頻通話(huà)或者觀(guān)看直播的過(guò)程當中打開(kāi)另外的應用而不用退出當前視頻。更詳細的就不再累述了,大家去閱讀官方文檔就行。
      這里以 Agora SDK 為例來(lái)給大家展示下該特性,實(shí)際上不用 Agora SDK 做任何修改。
      準備環(huán)境
    • Android 8.0 或以上版本手機
    • Agora SDK 1.14.0 或 以上 版本
    • Android Studio 3.0 或以上版本(非必需)
      如何實(shí)現畫(huà)中畫(huà)模式
      默認應用是不支持畫(huà)中畫(huà)模式的,需要給視頻所在的 Activity 做些配置,如下在 AnroidManifest.xml加上屬性 resizeableActivity/supportsPictureInPicture 并均設置為 true
    • android:resizeableActivity="true"
    • android:supportsPictureInPicture="true"
    • android:configChanges=
    • "screenSize|smallestScreenSize|screenLayout|orientation"
      為了進(jìn)入畫(huà)中畫(huà)模式,Activty 必需要用 enterPictureInPictureMode(PictureInPictureParams params)方法,非常的簡(jiǎn)單,但是為了告訴系統進(jìn)入畫(huà)中畫(huà)模式之后,Activity 界面在整個(gè)屏幕當中的布局,我們需要設置一些參數。我們這里簡(jiǎn)單設置下,具體在使用的時(shí)候需要根據屏幕的分辨率動(dòng)態(tài)取設置,更多信息參考 官方文檔。
      PictureInPictureParams params = new PictureInPictureParams.Builder()
    • setAspectRatio(new Rational(10, 16))
    • build();
      當然需要在程序當中控制 Acticity 界面當中的內容,比如我們可以隱藏自己本地的預覽畫(huà)面,隱藏不需要的按鈕信息等等,這個(gè)實(shí)現也非常簡(jiǎn)單。
      @Override
      public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
      super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
      FrameLayout container = findViewById(R.id.local_video_view_container);
      SurfaceView surfaceView = (SurfaceView) container.getChildAt(0);
      surfaceView.setZOrderMediaOverlay(!isInPictureInPictureMode);
      surfaceView.setVisibility(isInPictureInPictureMode ? View.GONE : View.VISIBLE);
      container.setVisibility(isInPictureInPictureMode ? View.GONE : View.VISIBLE);
      }
      另外值得一說(shuō)的是,進(jìn)入畫(huà)中畫(huà)模式,系統會(huì )觸發(fā)生命周期的方法 onPause/onResume 方法,我們需要根據需要適當的做些操作,比如是畫(huà)中畫(huà)模式的話(huà),就不做任何操作,音視頻流繼續,否則的話(huà),就關(guān)閉視頻流,反正在后臺也看不見(jiàn)視頻。
      運行截圖
      開(kāi)始行動(dòng)吧
      還等什么,了解了這些之后,快給自己的應用加上這個(gè)功能吧。我們也提供了 示例代碼供參考。
      Agora SDK下載鏈接:https://document.agora.io/cn/2.0/sdk/
      Android官方文檔:https://developer.android.com/guide/topics/ui/picture-in-picture.html
      示例代碼:https://github.com/AgoraIO/Agora-Picture-in-Picture-Android
      課程預告:從0開(kāi)發(fā)Android視頻通話(huà)
      時(shí)間:12月13日(周三)16:00-17:00
      內容:
    • 通信和直播的基本概念
    • Agora.SDK 2.0重大更新介紹
    • Agora Android SDK API調用邏輯
    • 開(kāi)發(fā)環(huán)境準備
    • 快速完成一個(gè)Agora android demo,功能包括:創(chuàng )建頻道、加入頻道、創(chuàng )建視頻通話(huà)、離開(kāi)頻道、開(kāi)關(guān)攝像頭、靜音、畫(huà)中畫(huà)。
    • 如何測試。視頻通話(huà)需要進(jìn)行哪些測試,如何進(jìn)行簡(jiǎn)單的測試
    • Q&A
    【免責聲明】本文僅代表作者本人觀(guān)點(diǎn),與CTI論壇無(wú)關(guān)。CTI論壇對文中陳述、觀(guān)點(diǎn)判斷保持中立,不對所包含內容的準確性、可靠性或完整性提供任何明示或暗示的保證。請讀者僅作參考,并請自行承擔全部責任。

    專(zhuān)題

    亚洲精品网站在线观看不卡无广告,国产a不卡片精品免费观看,欧美亚洲一区二区三区在线,国产一区二区三区日韩 临颍县| 新干县| 宜川县| 平果县| 永州市| 香河县| 都匀市| 肥西县| 兴业县| 富宁县| 崇仁县| 肇庆市| 肃宁县| 新乡县| 南安市| 襄城县| 石城县| 衢州市| 桐柏县| 通化县| 五常市| 伊宁市| 卢龙县| 托里县| 东乡县| 赤峰市| 都江堰市| 察哈| 阳朔县| 天长市| 澄城县| 额尔古纳市| 丰宁| 永平县| 大竹县| 凤城市| 阿拉善左旗| 铁力市| 无锡市| 邯郸市| 武平县| http://444 http://444 http://444 http://444 http://444 http://444