media_kit 1.1.6 copy "media_kit: ^1.1.6" to clipboard
media_kit: ^1.1.6 copied to clipboard

A cross-platform video player & audio player for Flutter & Dart. Performant, stable, feature-proof & modular.

example/README.md

// Make sure to add following packages to pubspec.yaml:
// * media_kit
// * media_kit_video
// * media_kit_libs_video
import 'package:flutter/material.dart';

import 'package:media_kit/media_kit.dart';                      // Provides [Player], [Media], [Playlist] etc.
import 'package:media_kit_video/media_kit_video.dart';          // Provides [VideoController] & [Video] etc.

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // Necessary initialization for package:media_kit.
  MediaKit.ensureInitialized();
  runApp(
    const MaterialApp(
      home: MyScreen(),
    ),
  );
}

class MyScreen extends StatefulWidget {
  const MyScreen({Key? key}) : super(key: key);
  @override
  State<MyScreen> createState() => MyScreenState();
}

class MyScreenState extends State<MyScreen> {
  // Create a [Player] to control playback.
  late final player = Player();
  // Create a [VideoController] to handle video output from [Player].
  late final controller = VideoController(player);

  @override
  void initState() {
    super.initState();
    // Play a [Media] or [Playlist].
    player.open(Media('https://user-images.githubusercontent.com/28951144/229373695-22f88f13-d18f-4288-9bf1-c3e078d83722.mp4'));
  }

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

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.width * 9.0 / 16.0,
        // Use [Video] widget to display video output.
        child: Video(controller: controller),
      ),
    );
  }
}
608
likes
0
pub points
98%
popularity

Publisher

verified publishermedia-kit.dev

A cross-platform video player & audio player for Flutter & Dart. Performant, stable, feature-proof & modular.

Repository (GitHub)
View/report issues

Topics

#video #video-player #audio #audio-player #cross-platform

Funding

Consider supporting this project:

www.github.com

License

unknown (license)

Dependencies

collection, http, image, js, meta, path, safe_local_storage, synchronized, universal_platform, uri_parser, uuid

More

Packages that depend on media_kit