Untitled
faisalsalameh
dart
a year ago
1.8 kB
1
Indexable
Never
import 'package:chewie/chewie.dart'; import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Video Stream Demo', home: VideoStreamPlayer(), ); } } class VideoStreamPlayer extends StatefulWidget { const VideoStreamPlayer({super.key}); @override _VideoStreamPlayerState createState() => _VideoStreamPlayerState(); } class _VideoStreamPlayerState extends State<VideoStreamPlayer> { VideoPlayerController? _controller; ChewieController? chewieController; Chewie? playerWidget; bool load = false; @override void initState() { super.initState(); _controller = VideoPlayerController.network( 'https://live1.panet.co.il/edge_abr/halaTV/playlist.m3u8'); chewieController = ChewieController(videoPlayerController: _controller!); _controller!.setLooping(true); _controller!.initialize().then((_) { setState(() { load = true; }); }); } @override Widget build(BuildContext context) { if (_controller!.value.isInitialized) { return Scaffold( appBar: AppBar(), body: Center( child: Stack( children: [ AspectRatio( aspectRatio: 16/9, child: Chewie( controller: chewieController!, ), ) ], ), ), ); } else { return const Center(child: CircularProgressIndicator()); } } @override void dispose() { super.dispose(); _controller!.dispose(); chewieController!.dispose(); } }