faliplayer 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

FAliplayer #

Flutter版的阿里云列表播放器,支持边播边缓存

GitHub license

示例效果 #

gif图加载慢请耐心等待

点击此处看视频效果

引入 #

import 'package:faliplayer/faliplayer.dart';

示例 #

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

class _MyAppState extends State<MyApp> {
  FAliListPlayerController controller;
  List<String> urls = [
        ...
  ];

  @override
  void initState() {
    super.initState();
    ///初始化
    controller = FAliListPlayerController(isAutoPlay: true, loop: true);
    ///添加视频源
    controller.addUrls(urls);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: FAliPlayerView.builder(
          controller: controller,
          ///视频列表每页的UI
          pageBuilder: (c, i) {
            return ...;
          },
          ///每个视频的缩略图
          thumbImageBuilder: (c, i, h, w) {
            return ...;
          },
        ),
      ),
    );
  }
}

控制播放 #

//开始
controller.start();
//暂停
controller.pause();
//移动到某个视频并播放
controller.moveTo(0);
//下一个
controller.moveToNext();
//上一个
controller.moveToPre();
//跳转
controller.seekTo(positon);

监听 #

//播放位置更新监听
controller.setPositionUpdateListener((position) {

});

//缓存位置更新监听
controller.setBufferedPositionUpdateListener((position) {

});

//视频大小变化监听
controller.setOnVideoSizeChanged((){

});

//视频播放事件变化监听
controller.setOnPlayEventListener((type){
      
});

设置缓存配置 #

请在初始化的视频设置,正常在initState处设置

controller.setCacheConfig(
          AVPCacheConfig(path: d.path, maxDuration: 100, maxSizeMB: 1024));

获取缓存文件的路径 #

///获取缓存文件的路径
///[url]文件的url
Future<void> getCachePath(String url)

设置视频显示模式 #

Future<void> setScalingMode(AVPScalingMode mode)
属性说明
SCALETOFILL拉伸(会变形)
SCALEASPECTFIT按照原比例显示
SCALEASPECTFILL按照原比例显示并充满屏幕

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:faliplayer/faliplayer.dart';
void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  FAliListPlayerController controller;
  bool a = true;
  List<String> urls = [
    "http://video.iqingbai.com/202002181038474liyNnnSzz.mp4",
    "http://video.iqingbai.com/20200218025702PSiVKDB5ap.mp4",
    "http://video.iqingbai.com/v0200f010000bpoujm68qblf351u7kqg.MP4",
    "http://video.iqingbai.com/v0200f230000bpoos459688r4f4ktnq0.MP4",
    "http://video.iqingbai.com/v0200fd60000bpouklebn5vab8nv6es0.MP4",
    "http://video.iqingbai.com/v0200fa00000bpnf14kmavfcq3piinkg.MP4",
    "http://video.iqingbai.com/v0200f9a0000bpkr35j2ap9cj5gjvlqg.MP4",
    "http://video.iqingbai.com/v0200f8a0000bpou2mnu9qbego7fpu0g.MP4",
    "http://video.iqingbai.com/v0200f8a0000bpoth05ds13erv5id0q0.MP4",
    "http://video.iqingbai.com/v0200f8a0000bport5nu9qbego7dimhg.MP4",
    "http://video.iqingbai.com/v0200f7a0000bpkcgvsuatl02d672cv0.MP4",
    "http://video.iqingbai.com/v0200f660000bpo8shqgd9fp1sds10k0.MP4",
    "http://video.iqingbai.com/v0200f530000bporepf3cp5e6ui4g5og.MP4",
    "http://video.iqingbai.com/v0200f530000bpob7ksm7fic1j4pi090.MP4",
  ];

  @override
  void initState() {
    super.initState();
    controller = FAliListPlayerController(isAutoPlay: true, loop: true);
    controller.addUrls(urls);
    controller.setCacheConfig(
        AVPCacheConfig(path: "hjhh", maxDuration: 100, maxSizeMB: 1024));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: FAliListPlayerView.builder(
          controller: controller,
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            print('111111');
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  faliplayer: ^0.0.1

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:faliplayer/faliplayer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
44
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:faliplayer/faliplayer.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:faliplayer/faliplayer.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:faliplayer/faliplayer.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:faliplayer/faliplayer.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [faliplayer] that is in a package requiring null.

Health suggestions

Format lib/faliplayer.dart.

Run flutter format to format lib/faliplayer.dart.

Format lib/src/aliplayer.dart.

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

Format lib/src/controller.dart.

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

Format lib/src/list/alilistcontroller.dart.

Run flutter format to format lib/src/list/alilistcontroller.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test