fix: stop player when navigating away

closes #24
This commit is contained in:
2025-05-16 16:55:44 +01:00
parent e91807e80e
commit 8173eab05d
6 changed files with 198 additions and 161 deletions

View File

@ -88,6 +88,7 @@ class ProfileWidget extends StatelessWidget {
final List<Widget>? children;
final bool? showName;
final double? spacing;
final bool? linkToProfile;
const ProfileWidget({
super.key,
@ -97,6 +98,7 @@ class ProfileWidget extends StatelessWidget {
this.children,
this.showName,
this.spacing,
this.linkToProfile,
});
static Widget pubkey(
@ -106,6 +108,7 @@ class ProfileWidget extends StatelessWidget {
bool? showName,
double? spacing,
Key? key,
bool? linkToProfile,
}) {
return ProfileLoaderWidget(pubkey, (ctx, state) {
return ProfileWidget(
@ -114,6 +117,7 @@ class ProfileWidget extends StatelessWidget {
showName: showName,
spacing: spacing,
key: key,
linkToProfile: linkToProfile,
children: children,
);
});
@ -125,7 +129,12 @@ class ProfileWidget extends StatelessWidget {
spacing: spacing ?? 8,
children: [
AvatarWidget(profile: profile, size: size),
if (showName ?? true) ProfileNameWidget(profile: profile, key: key),
if (showName ?? true)
ProfileNameWidget(
profile: profile,
key: key,
linkToProfile: linkToProfile,
),
...(children ?? []),
],
);

View File

@ -28,7 +28,7 @@ class StreamInfoWidget extends StatelessWidget {
spacing: 8,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ProfileWidget.pubkey(stream.info.host),
ProfileWidget.pubkey(stream.info.host, linkToProfile: false),
FollowButton(
pubkey: stream.info.host,
onTap: () {

View File

@ -23,19 +23,21 @@ class VideoPlayerWidget extends StatefulWidget {
}
class _VideoPlayerWidget extends State<VideoPlayerWidget> {
late final VideoPlayerController _controller;
late final ChewieController _chewieController;
@override
void initState() {
super.initState();
final controller = VideoPlayerController.networkUrl(
_controller = VideoPlayerController.networkUrl(
Uri.parse(widget.url),
httpHeaders: Map.from({"user-agent": userAgent}),
);
_chewieController = ChewieController(
videoPlayerController: controller,
videoPlayerController: _controller,
autoPlay: widget.autoPlay ?? true,
aspectRatio: widget.aspectRatio,
autoInitialize: true,
placeholder:
(widget.placeholder?.isNotEmpty ?? false)
@ -46,8 +48,9 @@ class _VideoPlayerWidget extends State<VideoPlayerWidget> {
@override
void dispose() {
super.dispose();
_controller.dispose();
_chewieController.dispose();
super.dispose();
}
@override