cp_hls_video_player 0.0.2 copy "cp_hls_video_player: ^0.0.2" to clipboard
cp_hls_video_player: ^0.0.2 copied to clipboard

discontinued
PlatformAndroidiOS

Adaptive HLS Video Player

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final CPHlsVideoPlayerController _controller = CPHlsVideoPlayerController();

  @override
  initState(){
    super.initState();
    _controller.setSeekStartListener((position, totalDuration) {
      debugPrint("***********> Seek start> Position: ${position.inSeconds},  Total: ${totalDuration.inSeconds}");
    });
    _controller.setSeekEndListener((position, totalDuration) {
      debugPrint("***********> Seek end> Position: ${position.inSeconds},  Total: ${totalDuration.inSeconds}");
    });
    _controller.setStateListener((isPlaying, isEnded, currentPosition, totalDuration) {
      debugPrint("***********> State changed> IsPlaying: $isPlaying, IsEnded: $isEnded Position: ${currentPosition.inSeconds},  Total: ${totalDuration.inSeconds}");
    });
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      _controller.loadHLSVideo("https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        top: MediaQuery.of(context).orientation == Orientation.portrait,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            CPHlsVideoPlayer(
              controller: _controller,
            ),
          ],
        ),
      ),
      floatingActionButton: GestureDetector(
        onTap: (){
          _controller.loadHLSVideo("https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8");
        },
        child: const Icon(
          Icons.ac_unit,
          size: 64,
        ),
      ),
    );
  }
}
1
likes
120
points
28
downloads

Publisher

unverified uploader

Weekly Downloads

Adaptive HLS Video Player

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

better_player, flutter

More

Packages that depend on cp_hls_video_player

Packages that implement cp_hls_video_player