59 lines
1.5 KiB
Dart
59 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:media_kit/media_kit.dart';
|
|
import 'package:media_kit_video/media_kit_video.dart';
|
|
|
|
class TVPlayerScreen extends StatefulWidget {
|
|
final String url;
|
|
final String? title;
|
|
|
|
const TVPlayerScreen({super.key, required this.url, this.title});
|
|
|
|
@override
|
|
State<TVPlayerScreen> createState() => _TVPlayerScreenState();
|
|
}
|
|
|
|
class _TVPlayerScreenState extends State<TVPlayerScreen> {
|
|
late final player = Player();
|
|
late final controller = VideoController(player);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
player.open(Media(widget.url));
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
player.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.black,
|
|
body: Stack(
|
|
children: [
|
|
Video(controller: controller),
|
|
if (widget.title != null)
|
|
Positioned(
|
|
top: 40,
|
|
left: 40,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
color: Colors.black54,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Text(
|
|
widget.title!,
|
|
style: const TextStyle(color: Colors.white, fontSize: 24),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|