Send the sign-in with native video playback

The native video player requests media itself, without the session
cookie the app's file fetches send, so a video shown with show_file (or
opened from Files) behind the web login was refused in the phone and Mac
apps. Pass ServerSession.headersFor(uri) as the player's HTTP headers.
This commit is contained in:
2026-11-12 23:18:44 +00:00
parent a440859108
commit 26e68140fd
2 changed files with 40 additions and 1 deletions
@@ -1,12 +1,21 @@
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import '../../../core/session/server_session.dart';
/// Creates the player for one media url; tests inject a fake controller.
typedef ArtifactVideoControllerFactory =
VideoPlayerController Function(Uri uri);
/// The native players request the media themselves, outside the app's own
/// fetch, so they carry the same sign-in the app's file fetches send (the web
/// login's session cookie for a trusted server). A browser's `<video>` sends
/// its cookie itself and ignores these headers.
VideoPlayerController defaultArtifactVideoController(Uri uri) =>
VideoPlayerController.networkUrl(uri);
VideoPlayerController.networkUrl(
uri,
httpHeaders: ServerSession.headersFor(uri),
);
const String artifactVideoPlayLabel = 'Play video';
const String artifactVideoPauseLabel = 'Pause video';