fplayer 1.0.0 copy "fplayer: ^1.0.0" to clipboard
fplayer: ^1.0.0 copied to clipboard

outdated

A Video Player Flutter plugin based on fijkplayer, support most popular protocols and codecs.

fplayer (Video player plugin for Flutter) Flutter 媒体播放器 #

A Flutter media player plugin for iOS and android based on fijkplayer

您的支持是我们开发的动力。 欢迎Star,欢迎PR~。 Feedback welcome and Pull Requests are most welcome!

Documentation 文档 #

  • 开发文档 https://fplayer.dev/ 包含首页、入门指南、基础、内核、fplayer 中的概念理解

Installation 安装 #

Add fplayer as a dependency in your pubspec.yaml file.

pub package

dependencies:
  fplayer: ^{{latest version}}

Replace {{latest version}} with the version number in badge above.

Use git branch which not published to pub.

dependencies:
  fplayer:
    git:
      url: https://github.com/FlutterPlayer/fplayer.git
      ref: develop # can be replaced to branch or tag name

Example 示例 #

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:fplayer/fplayer.dart';

import 'app_bar.dart';
// import 'custom_ui.dart';

class VideoScreen extends StatefulWidget {
  final String url;

  const VideoScreen({super.key, required this.url});

  @override
  VideoScreenState createState() => VideoScreenState();
}

class VideoScreenState extends State<VideoScreen> {
  final FPlayer player = FPlayer();

  VideoScreenState();

  @override
  void initState() {
    super.initState();
    player.setOption(FOption.hostCategory, "enable-snapshot", 1);
    player.setOption(FOption.playerCategory, "mediacodec-all-videos", 1);
    startPlay();
  }

  void startPlay() async {
    await player.setOption(FOption.hostCategory, "request-screen-on", 1);
    await player.setOption(FOption.hostCategory, "request-audio-focus", 1);
    await player.setDataSource(widget.url, autoPlay: true).catchError((e) {
      if (kDebugMode) {
        print("setDataSource error: $e");
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const FAppBar.defaultSetting(title: "Video"),
      body: Center(
        child: FView(
          player: player,
          panelBuilder: fPanel2Builder(
            title: '视频标题',
            subTitle: '视频副标题',
            // 右下方截屏按钮
            snapShot: true,
            // 右上方按钮组
            rightButton: true,
            rightButtonList: [
              InkWell(
                onTap: () {},
                child: Container(
                  padding: const EdgeInsets.all(10),
                  decoration: const BoxDecoration(
                    color: Color(0x33000000),
                    borderRadius: BorderRadius.vertical(
                      top: Radius.circular(5),
                    ),
                  ),
                  child: const Icon(
                    Icons.favorite,
                    color: Color(0xFF07B9B9),
                  ),
                ),
              ),
              InkWell(
                onTap: () {},
                child: Container(
                  padding: const EdgeInsets.all(10),
                  decoration: const BoxDecoration(
                    color: Color(0x33000000),
                    borderRadius: BorderRadius.vertical(
                      bottom: Radius.circular(5),
                    ),
                  ),
                  child: const Icon(
                    Icons.thumb_up,
                    color: Color(0xFF07B9B9),
                  ),
                ),
              )
            ],
            caption: true,
            settingFun: () {
              print('设置按钮点击事件');
            },
            captionFun: () {
              print('字幕按钮点击事件');
            },
            resolution: true,
            resolutionFun: () {
              print('清晰度按钮点击事件');
            },
          ),
          fsFit: FFit.fill,
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
    player.release();
  }
}

鸣谢以下项目 #

iOS Warning 警告 #

Warning: The fplayer video player plugin is not functional on iOS simulators. An iOS device must be used during development/testing. For more details, please refer to this issue.

17
likes
0
points
59
downloads

Publisher

unverified uploader

Weekly Downloads

A Video Player Flutter plugin based on fijkplayer, support most popular protocols and codecs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

battery_plus, flutter, plugin_platform_interface

More

Packages that depend on fplayer

Packages that implement fplayer