Skip to content

Latest commit

 

History

History
104 lines (82 loc) · 2.77 KB

README.md

File metadata and controls

104 lines (82 loc) · 2.77 KB

GPlayer

pub package

Video Player plugin for Flutter,On Android, the backing player is base on ijkplayer 0.8.8 (not implement on iOS)

The example app running in Android

features

  1. base on ijkplayer(ffmpeg),support RTMP , HLS (http & https) , MP4,M4A etc.
  2. gestures for volume control
  3. gestures for brightness control
  4. gestures for forward or backward
  5. support fullscreen
  6. try to replay when error(only for live video)
  7. specify video scale type
  8. support lazy load (download player on demand)
  9. customize media controller (without change this project source code)

note: this using lazy load for default,it will take a few seconds to download decoders before first play, if you want to include the decoder in your apk just find the android/build.gradle and add the dependencies which you want to support.

Getting Started

1.add dependency

First, add gplayer as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter

  # add gplayer dependency
  gplayer: ^0.0.2

2.create player

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

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

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

class _MyAppState extends State<MyApp> {
  GPlayer player;
  @override
  void initState() {
    super.initState();
    //1.create & init player
    player = GPlayer(uri: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4')
      ..init()
      ..addListener((_) {
        //update control button out of player
        setState(() {});
      });
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        appBar: AppBar(
          title: Text('GPlayer'),
        ),
        body: player.display,//3.put the player display in Widget tree
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              player.isPlaying ? player.pause() : player.start();
            });
          },
          child: Icon(
            player.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }
}

Customize media contoller

1.define a class extend from buildMediaController

2.implement method Widget buildMediaController(BuildContext context)

3.pass the instance to player constructor GPlayer(uri:'',mediaController:MyMeidaController())