| 1 | import 'package:fastpix_player/fastpix_video_player.dart'; |
| 2 | import 'package:flutter/material.dart'; |
| 3 | |
| 4 | import { PageSchema } from "../../../../components/PageSchema"; |
| 5 | |
| 6 | <PageSchema |
| 7 | headline={"Flutter Player: Complete integration example | FastPix"} |
| 8 | description={"See a complete integration with the FastPix Flutter player SDK. Step-by-step guide with runnable Dart code and adaptive HLS playback for your app right now."} |
| 9 | url={"https://fastpix.com/docs/flutter-player/complete-integration-example"} |
| 10 | breadcrumb={["Video Player", "Flutter player", "Examples", "Complete integration example"]} |
| 11 | /> |
| 12 | |
| 13 | void main() { |
| 14 | runApp(const MyApp()); |
| 15 | } |
| 16 | |
| 17 | class MyApp extends StatelessWidget { |
| 18 | const MyApp({super.key}); |
| 19 | |
| 20 | @override |
| 21 | Widget build(BuildContext context) { |
| 22 | return MaterialApp( |
| 23 | title: 'Fastpix Player Demo', |
| 24 | theme: ThemeData( |
| 25 | colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), |
| 26 | ), |
| 27 | home: const FastPixPlayerDemo(), |
| 28 | ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | class FastPixPlayerDemo extends StatefulWidget { |
| 33 | const FastPixPlayerDemo({super.key}); |
| 34 | |
| 35 | @override |
| 36 | State<FastPixPlayerDemo> createState() => _FastPixPlayerDemoState(); |
| 37 | } |
| 38 | |
| 39 | class _FastPixPlayerDemoState extends State<FastPixPlayerDemo> { |
| 40 | late FastPixPlayerController controller; |
| 41 | |
| 42 | @override |
| 43 | void initState() { |
| 44 | super.initState(); |
| 45 | |
| 46 | // Create HLS data source |
| 47 | final dataSource = FastPixPlayerDataSource.hls( |
| 48 | playbackId: 'your-playback-id-here', |
| 49 | title: 'Sample HLS Stream', |
| 50 | description: 'A sample HLS stream from FastPix', |
| 51 | thumbnailUrl: 'https://www.example.com/thumbnail.jpg', |
| 52 | ); |
| 53 | |
| 54 | final configuration = FastPixPlayerConfiguration(); |
| 55 | controller = FastPixPlayerController(); |
| 56 | controller.initialize(dataSource: dataSource, configuration: configuration); |
| 57 | } |
| 58 | |
| 59 | @override |
| 60 | Widget build(BuildContext context) { |
| 61 | return FastPixPlayer( |
| 62 | controller: controller, |
| 63 | width: 350, |
| 64 | height: 200, |
| 65 | aspectRatio: FastPixAspectRatio.ratio16x9, |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | @override |
| 70 | void dispose() { |
| 71 | controller.dispose(); |
| 72 | super.dispose(); |
| 73 | } |
| 74 | } |