gplayer 0.0.1 copy "gplayer: ^0.0.1" to clipboard
gplayer: ^0.0.1 copied to clipboard

outdated

A video player for Flutter base on ijkplayer.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:gplayer/defaultmediacontrol.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();
    player = GPlayer(
        uri: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4',
        options: [Option(1, 'multiple_requests', 1)], 
        mediaController: DefaultMediaController(title: 'bunny bear'))
      ..init()
      ..addListener((_) {
        //update control button out of player
        setState(() {});
      });
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        appBar: AppBar(
          title: Text('GPlayer'),
        ),
        body: SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.only(top: 0),
            child: Column(
              children: <Widget>[
                AspectRatio(
                  aspectRatio: 16 / 9,
                  child: player.display,
                ),
                Padding(
                  padding: EdgeInsets.all(18),
                  child: Row(
                    children: <Widget>[
                      Text('landscapeWhenFullScreen:'),
                      Switch(
                          value: player.landscapeWhenFullScreen,
                          onChanged: (_) {
                            player.landscapeWhenFullScreen = _;
                            setState(() {
                              
                            });
                          })
                    ],
                  ),
                )
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              player.isPlaying ? player.pause() : player.start();
            });
          },
          child: Icon(
            player.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }
}
11
likes
30
pub points
25%
popularity

Publisher

unverified uploader

A video player for Flutter base on ijkplayer.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, uuid

More

Packages that depend on gplayer