EasyRTMP 1.3.17.1014版本更新
這個版本主要更新了如下内容:
-
關于界面調整.
由于業務需求,app的關于界面需要同時起到我們産品宣傳的作用,是以我們決定将關于界面内容更完善些,于是乎就改成如下這樣子:
這個界面使用了ConstrantLayout進行布局.其代碼如下:EasyRTMP 1.3.17.1014版本更新 <?xml version="1.0" encoding="utf-8"?> <layout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:text="EasyRTMP是一套調用簡單、功能完善、運作高效穩定的RTMP功能元件,經過多年實戰和線上運作打造,支援RTMP推送斷線重連、環形緩沖、智能丢幀、網絡事件回調,支援Windows、Linux、arm(hisiv100/hisiv200/hisiv300/hisiv400/etc..)、Android、iOS平台,支援市面上絕大部分的RTMP流媒體伺服器,能夠完美應用于各種行業的直播需求,手機直播、桌面直播、錄影機直播、課堂直播等等方面!\n配套方案推薦:" android:layout_width="0dp" android:layout_height="wrap_content" android:id="@+id/desc" android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="@+id/toolbar" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" android:layout_marginStart="16dp" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:layout_marginRight="16dp" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginTop="8dp" android:id="@+id/rtmp_title" android:layout_marginRight="16dp" android:text="-EasyRTMP推流元件:" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/desc" /> <ImageView android:id="@+id/imageView" android:layout_width="156dp" android:layout_height="156dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:layout_marginTop="8dp" android:src="@drawable/android_rtmp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/guideline" app:layout_constraintTop_toBottomOf="@+id/rtmp_title" /> <TextView android:layout_width="wrap_content" android:text="Android" app:layout_constraintTop_toBottomOf="@+id/imageView" android:layout_marginStart="16dp" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:id="@+id/android_rtmp_title" android:layout_marginTop="8dp" app:layout_constraintRight_toLeftOf="@+id/guideline" android:layout_height="wrap_content" /> <android.support.constraint.Guideline android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/guideline" app:layout_constraintGuide_percent="0.5" android:orientation="vertical" /> <ImageView android:id="@+id/imageView2" android:layout_width="156dp" android:layout_height="156dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:layout_marginTop="8dp" android:src="@drawable/ios_rtmp" app:layout_constraintLeft_toRightOf="@+id/guideline" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/rtmp_title" /> <TextView android:layout_width="wrap_content" android:text="iOS" app:layout_constraintTop_toBottomOf="@+id/imageView2" android:layout_marginStart="16dp" app:layout_constraintRight_toRightOf="parent" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="8dp" app:layout_constraintLeft_toRightOf="@+id/guideline" android:layout_height="wrap_content" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginTop="8dp" android:id="@+id/server_title" android:layout_marginRight="16dp" android:text="-EasyDSS RTMP流媒體伺服器:\nhttp://www.easydss.com" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/android_rtmp_title" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginTop="8dp" android:id="@+id/player_title" android:layout_marginRight="16dp" android:text="-EasyPlayerPro全功能播放器:\nhttps://github.com/EasyDSS/EasyPlayerPro" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/server_title" /> <ImageView android:id="@+id/imageView_player_pro_android" android:layout_width="156dp" android:layout_height="156dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:layout_marginTop="8dp" android:src="@drawable/android_player_pro" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@+id/guideline" app:layout_constraintTop_toBottomOf="@+id/player_title" /> <TextView android:layout_width="wrap_content" android:text="Android" app:layout_constraintTop_toBottomOf="@+id/imageView_player_pro_android" android:layout_marginStart="16dp" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:id="@+id/android_player_pro_title" android:layout_marginTop="8dp" app:layout_constraintRight_toLeftOf="@+id/guideline" android:layout_height="wrap_content" /> <ImageView android:id="@+id/imageView_player_pro_ios" android:layout_width="156dp" android:layout_height="156dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:layout_marginTop="8dp" android:src="@drawable/ios_player_pro" app:layout_constraintLeft_toRightOf="@+id/guideline" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/player_title" /> <TextView android:layout_width="wrap_content" android:text="iOS" app:layout_constraintTop_toBottomOf="@+id/imageView_player_pro_ios" android:layout_marginStart="16dp" app:layout_constraintRight_toRightOf="parent" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="8dp" app:layout_constraintLeft_toRightOf="@+id/guideline" android:layout_height="wrap_content" /> <TextView android:text="Copyright © EasyDarwin.org 2012-2017" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/textView3" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/android_player_pro_title" android:layout_marginBottom="8dp" android:layout_marginStart="16dp" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="16dp" android:layout_marginEnd="16dp" android:layout_marginTop="16dp" app:layout_constraintRight_toRightOf="parent" android:layout_marginRight="16dp" android:layout_width="0dp" /> </android.support.constraint.ConstraintLayout> </ScrollView> </layout>
- 支援x86,mips架構
-
在6.0及以上系統上,動态擷取攝像頭以及錄音權限.
安卓6.0以上增加了動态權限的功能.有些權限,比如攝像頭和錄音權限,不僅需要在Manifest裡面申請,還需要在APP運作時動态擷取.而如果APP的targetVersion值設定在6.0以下,那系統會做相容,不需要再動态擷取即可.這個版本我們适配了動态權限.
在StreamActivity入口,首先檢查是否有了相關權限了?如果沒有的話,那就去申請.
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.CAMERA, android.Manifest.permission.RECORD_AUDIO}, REQUEST_CAMERA_PERMISSION); mNeedGrantedPermission = true; return; } else { // resume.. }
在發送requestPermissions後,系統會彈出對話框讓使用者确認,使用者确認後會進入onRequestPermissionsResult回調.在回調裡面再判斷使用者是否同意了.
當使用者同意授權後,再啟動攝像頭進行推送.
-
在背景上傳視訊時,需要動态擷取”顯示在頂層”權限.
在6.0及以上的系統,對TYPE_SYSTEM_OVERLAY這種格式的VIEW進行了限制,應用程式需要擷取“運作在頂層”才可以建立這種view.我們需要建立這種view來進行視訊采集.Android提供了方法來判斷是否擁有該權限了:
Settings.canDrawOverlays(this);
與普通權限擷取不一樣的是,這種權限需要打開設定界面進行授權,在onActivityResult裡面檢查授權情況.我們在設定界面,勾選使能背景采集時,向使用者申請這種權限.
相關代碼如下:
在onActivityResult裡判斷是否擷取到了該權限:if (!Settings.canDrawOverlays(SettingActivity.this)) { new AlertDialog.Builder(SettingActivity.this).setTitle("背景上傳視訊").setMessage("背景上傳視訊需要APP出現在頂部.是否确定?").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + BuildConfig.APPLICATION_ID)); startActivityForResult(intent, REQUEST_OVERLAY_PERMISSION); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { PreferenceManager.getDefaultSharedPreferences(SettingActivity.this).edit() .putBoolean(KEY_ENABLE_BACKGROUND_CAMERA, false).apply(); buttonView.toggle(); } }).setCancelable(false).show(); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_OVERLAY_PERMISSION) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean canDraw = Settings.canDrawOverlays(this); PreferenceManager.getDefaultSharedPreferences(SettingActivity.this).edit() .putBoolean(KEY_ENABLE_BACKGROUND_CAMERA, canDraw).apply(); if (!canDraw){ CheckBox backgroundPushing = (CheckBox) findViewById(R.id.enable_background_camera_pushing); backgroundPushing.setChecked(false); } } } }
關于EasyRTMP推流SDK
EasyRTMP是一套調用簡單、功能完善、運作高效穩定的RTMP功能元件,經過多年實戰和線上運作打造,支援RTMP推送斷線重連、環形緩沖、智能丢幀、網絡事件回調,支援Windows、Linux、arm(hisiv100/hisiv200/hisiv300/hisiv400/etc..)、Android、iOS平台,支援市面上絕大部分的RTMP流媒體伺服器,包括Red5、Ngnix_rtmp、crtmpserver等主流RTMP伺服器,能夠完美應用于各種行業的直播需求,手機直播、桌面直播、錄影機直播、課堂直播等等方面!
點選連結加入群【EasyRTMP-RTMP直播推送】:587254841
擷取更多資訊
郵件:[email protected]
WEB:www.EasyDarwin.org
Copyright © EasyDarwin.org 2012-2017