flutter_rtmp 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 77

flutter_rtmp #

使用方法 #

git安装使用时建议要按照release版本号

引入 #

1.第一种方法

flutter_rtmp:
   git: https://github.com/MEnigma/flutter_rtmp.git
   ref: ***

2.第二种

flutter_rtmp: ^*.*.*

关于iOS的配置

需要在info.plist中添加 

<key>io.flutter.embedded_views_preview</key>
<true/>

关于Android的配置

目前仅支持armv7架构

android{
    ...
    defaultConfig{
        ...
        ndk{
            abiFilters "armeabi-v7a"
        }
    }
}

示例

   /// 控制器
   void initState() {
       super.initState();
       _manager = RtmpManager(onCreated: () {
           print("--- view did created ---");
       });
   }

   /// 视图
  Widget build(BuildContext context) {

     return RtmpView(
           manager: _manager,
      );
  }

引用 #

进度 #

  • [x] 推流
  • [x] 切换摄像头
  • [ ] 美颜
  • [ ] 旋转 (android端会根据宽高比调整横竖屏)

LICENSE #

  • 参与者

0.1.1 #

  • TODO: release

0.1.3 #

  • TODO: 1.修改timer刷新重复绑定问题

0.1.4 #

  • 1.修复父节点刷新时重复绑定问题
  • 2.当前结构下,PlatformView依赖于RtmpManager,所以建议RtmpManager设置为属性
class _MyAppState extends State<MyApp> {
    RtmpManager _manager;

    @override
    void initState(){
        super.initState();
        // e.g 1
        //_manager = RtmpManager();
    }    

    @override
    Widget build(BuildContext context) {
        return RtmpView(
            //e.g 2
            manager:_manager ??= RtmpManager()
      );
  
}

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter_rtmp/flutter_rtmp.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  RtmpManager _manager;
  int count = 0;
  Timer _timer;

  @override
  void initState() {
    super.initState();
    _manager = RtmpManager(onCreated: () {
      print("--- view did created ---");
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          body: Center(
        child: SafeArea(
          child: Stack(
            fit: StackFit.expand,
            children: <Widget>[
              RtmpView(
                manager: _manager,
              ),
              Container(
                padding: EdgeInsets.only(top: 20),
                alignment: Alignment.topLeft,
                child: Row(
                  children: <Widget>[
                    IconButton(
                      icon: Icon(Icons.play_arrow),
                      onPressed: () {
                        _manager.living(
                            url: "<rtmp address>");
                        if (_timer == null)
                          _timer ??= Timer.periodic(Duration(seconds: 1), (_) {
                            setState(() {
                              count += 1;
                            });
                          });
                      },
                    ),
                    IconButton(
                      icon: Icon(Icons.pause),
                      onPressed: () {
                        _manager.pauseLive();
                        if (_timer != null) {
                          _timer.cancel();
                          _timer = null;
                        }
                        ;
                      },
                    ),
                    IconButton(
                      icon: Icon(Icons.switch_camera),
                      onPressed: () {
                        _manager.switchCamera();
                      },
                    ),
                    Container(
                      child: Text(
                        "${count ~/ 60}:${count % 60}",
                        style: TextStyle(fontSize: 17, color: Colors.blue),
                      ),
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      )),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_rtmp: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_rtmp/flutter_rtmp.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:flutter_rtmp/flutter_rtmp.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:flutter_rtmp/flutter_rtmp.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_rtmp/flutter_rtmp.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:flutter_rtmp/flutter_rtmp.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_rtmp that is a package requiring null.

Health suggestions

Fix lib/src/rtmp_view.dart. (-1 points)

Analysis of lib/src/rtmp_view.dart reported 2 hints:

line 12 col 8: Unused import: 'package:flutter_rtmp/src/def.dart'.

line 14 col 8: Unused import: 'package:permission_handler/permission_handler.dart'.

Format lib/src/models.dart.

Run flutter format to format lib/src/models.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (permission_handler).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
permission_handler ^3.2.0 3.3.0 5.0.1+1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test