EasyRTMP 1.3.17.1014版本更新

EasyRTMP 1.3.17.1014版本更新

这个版本主要更新了如下内容:

  • 关于界面调整.

    由于业务需求,app的关于界面需要同时起到我们产品宣传的作用,因此我们决定将关于界面内容更完善些,于是乎就改成如下这样子:
    关于界面

    这个界面使用了ConstrantLayout进行布局.其代码如下:

    <?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里面检查授权情况.我们在设置界面,勾选使能后台采集时,向用户申请这种权限.

    相关代码如下:

    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();
    }

    onActivityResult里判断是否获取到了该权限:

      @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

EasyDarwin

猜你喜欢

转载自blog.csdn.net/jyt0551/article/details/78235089