native_video_view_null_safe 0.5.0 copy "native_video_view_null_safe: ^0.5.0" to clipboard
native_video_view_null_safe: ^0.5.0 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(MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  @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(
            'https://kdweb-75176.gzc.vod.tencent-cloud.com/video_test_src/video_quality_improve_demo/NewYork_4K_HDR.mp4',
            sourceType: VideoSourceType.network,
            requestAudioFocus: true,
          );
        },
        onPrepared: (controller, info) {
          controller.play();
        },
        onError: (controller, what, extra, message) {
          print('Player Error ($what | $extra | $message)');
        },
        onCompletion: (controller) {
          print('Video completed');
        },
      ),
    );
  }
}
2
likes
30
pub points
0%
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

License

MIT (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on native_video_view_null_safe