qyplayer 0.1.2 copy "qyplayer: ^0.1.2" to clipboard
qyplayer: ^0.1.2 copied to clipboard

a versatile video player. Supports m3u8, flv, mp4, and more. Simple, yet powerful, with a clean interface for seamless video playback in your Flutter projects.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:qyplayer/interface/qyplayer_interface.dart';
import 'package:qyplayer/qyplayer.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'QYPlayer',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey<QYPlayerState> playerKey = GlobalKey<QYPlayerState>();

  QYPlayerController? controller;

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    controller = QYPlayerController(
      // src:
      //     'http://rbmn-live.akamaized.net/hls/live/590964/BoRB-AT/master_1660.m3u8',
      // src: 'http://live.m2.tv/hls3/stream.m3u8',
      src:
          'https://1500005690.vod2.myqcloud.com/43843704vodtranscq1500005690/57c0f251243791580257343139/adp.10.m3u8?t=65e1d812&us=3405534&sign=f26dcdbc5d73b646752ffddc39f85660',
      poster:
          'https://img2.baidu.com/it/u=3867960631,2923014190&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
      width: MediaQuery.of(context).size.width,
      height: MediaQuery.of(context).size.height / 2,
      isLive: false,
      initTime: const Duration(seconds: 12),
      autoplay: false,
      useSafeArea: true,
      bgColor: Colors.white,
      // defaultPlaybackRates: [
      //   const QYPlayerPlaybackRate('5.0X', 5.0),
      //   const QYPlayerPlaybackRate('4.0X', 4.0),
      //   const QYPlayerPlaybackRate('3.0X', 3.0),
      //   const QYPlayerPlaybackRate('2.0X', 2.0),
      //   const QYPlayerPlaybackRate('1.0X', 1.0),
      // ],
    );
  }

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        systemNavigationBarColor: Colors.black,
        statusBarColor: Colors.black,
        statusBarIconBrightness: Brightness.light,
      ),
    );
    return Scaffold(
      body: QYPlayer(
        key: playerKey,
        controller: controller!,
      ),
      // floatingActionButton: FloatingActionButton(
      //   onPressed: () {
      //     print('>>>>>>>>> ${controller!.isPlaying}');
      //   },
      // ),
    );
  }
}
5
likes
140
points
43
downloads

Documentation

API reference

Publisher

verified publisherdei3.com

Weekly Downloads

a versatile video player. Supports m3u8, flv, mp4, and more. Simple, yet powerful, with a clean interface for seamless video playback in your Flutter projects.

Repository

License

MIT (license)

Dependencies

flutter, provider, video_player

More

Packages that depend on qyplayer