From 54babaec89ec470721be2f8ca15cf089a77ed699 Mon Sep 17 00:00:00 2001 From: PartyDonut <42371342+PartyDonut@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:51:54 +0100 Subject: [PATCH] fix: STRM files not playing correctly (#210) Co-authored-by: PartyDonut --- lib/models/playback/playback_model.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/models/playback/playback_model.dart b/lib/models/playback/playback_model.dart index 16cbdb1..efc4fd8 100644 --- a/lib/models/playback/playback_model.dart +++ b/lib/models/playback/playback_model.dart @@ -204,6 +204,8 @@ class PlaybackModelHelper { final trickPlay = (await api.getTrickPlay(item: fullItem.body, ref: ref))?.body; final chapters = fullItem.body?.overview.chapters ?? []; + final mediaPath = isValidVideoUrl(mediaSource?.path ?? ""); + if (mediaSource == null) return null; if ((mediaSource.supportsDirectStream ?? false) || (mediaSource.supportsDirectPlay ?? false)) { @@ -230,7 +232,9 @@ class PlaybackModelHelper { chapters: chapters, playbackInfo: playbackInfo, trickPlay: trickPlay, - media: Media(url: '${ref.read(userProvider)?.server ?? ""}/Videos/${mediaSource.id}/stream?$params'), + media: Media( + url: mediaPath ?? '${ref.read(userProvider)?.server ?? ""}/Videos/${mediaSource.id}/stream?$params', + ), mediaStreams: mediaStreamsWithUrls, ); } else if ((mediaSource.supportsTranscoding ?? false) && mediaSource.transcodingUrl != null) { @@ -252,6 +256,11 @@ class PlaybackModelHelper { } } + String? isValidVideoUrl(String path) { + Uri? uri = Uri.tryParse(path); + return (uri != null && uri.hasScheme && uri.hasAuthority) ? path : null; + } + Future> collectQueue(ItemBaseModel model) async { switch (model) { case EpisodeModel _: