mirror of
https://github.com/nostrlabs-io/zap-stream-flutter.git
synced 2025-06-16 11:58:50 +00:00
feat: background playback (wip)
https://github.com/ryanheise/audio_service/issues/1124
This commit is contained in:
53
lib/widgets/video_player_main.dart
Normal file
53
lib/widgets/video_player_main.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:chewie/chewie.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:zap_stream_flutter/main.dart';
|
||||
|
||||
class MainVideoPlayerWidget extends StatefulWidget {
|
||||
final String url;
|
||||
final String? title;
|
||||
final String? placeholder;
|
||||
final double? aspectRatio;
|
||||
final bool? autoPlay;
|
||||
final bool? isLive;
|
||||
|
||||
const MainVideoPlayerWidget({
|
||||
super.key,
|
||||
required this.url,
|
||||
this.title,
|
||||
this.placeholder,
|
||||
this.aspectRatio,
|
||||
this.autoPlay,
|
||||
this.isLive,
|
||||
});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _MainVideoPlayerWidget();
|
||||
}
|
||||
|
||||
class _MainVideoPlayerWidget extends State<MainVideoPlayerWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
mainPlayer.loadUrl(
|
||||
widget.url,
|
||||
title: widget.title,
|
||||
placeholder: widget.placeholder,
|
||||
aspectRatio: widget.aspectRatio,
|
||||
autoPlay: widget.autoPlay,
|
||||
isLive: widget.isLive,
|
||||
artist: "zap.stream"
|
||||
);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
mainPlayer.stop();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Chewie(controller: mainPlayer.chewie!);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user