native_video_view 1.0.5 copy "native_video_view: ^1.0.5" to clipboard
native_video_view: ^1.0.5 copied to clipboard

A video player widget displayed using the platform native player (VideoView in Android and AVPlayer in iOS).

example/lib/main.dart

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

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: _buildVideoPlayerWidget(),
    );
  }

  Widget _buildVideoPlayerWidget() {
    return Container(
      alignment: Alignment.center,
      child: NativeVideoView(
        keepAspectRatio: true,
        showMediaController: true,
        enableVolumeControl: true,
        onCreated: (controller) {
          controller.setVideoSource(
            'assets/example.mp4',
            sourceType: VideoSourceType.asset,
            requestAudioFocus: true,
          );
        },
        onPrepared: (controller, info) {
          debugPrint('NativeVideoView: Video prepared');
          controller.play();
        },
        onError: (controller, what, extra, message) {
          debugPrint(
              'NativeVideoView: Player Error ($what | $extra | $message)');
        },
        onCompletion: (controller) {
          debugPrint('NativeVideoView: Video completed');
        },
      ),
    );
  }
}
50
likes
150
pub points
84%
popularity

Publisher

unverified uploader

A video player widget displayed using the platform native player (VideoView in Android and AVPlayer in iOS).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_plugin_android_lifecycle, path_provider

More

Packages that depend on native_video_view