Skip to content

Commit 54babae

Browse files
authored
fix: STRM files not playing correctly (#210)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
1 parent b470c26 commit 54babae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/models/playback/playback_model.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ class PlaybackModelHelper {
204204
final trickPlay = (await api.getTrickPlay(item: fullItem.body, ref: ref))?.body;
205205
final chapters = fullItem.body?.overview.chapters ?? [];
206206

207+
final mediaPath = isValidVideoUrl(mediaSource?.path ?? "");
208+
207209
if (mediaSource == null) return null;
208210

209211
if ((mediaSource.supportsDirectStream ?? false) || (mediaSource.supportsDirectPlay ?? false)) {
@@ -230,7 +232,9 @@ class PlaybackModelHelper {
230232
chapters: chapters,
231233
playbackInfo: playbackInfo,
232234
trickPlay: trickPlay,
233-
media: Media(url: '${ref.read(userProvider)?.server ?? ""}/Videos/${mediaSource.id}/stream?$params'),
235+
media: Media(
236+
url: mediaPath ?? '${ref.read(userProvider)?.server ?? ""}/Videos/${mediaSource.id}/stream?$params',
237+
),
234238
mediaStreams: mediaStreamsWithUrls,
235239
);
236240
} else if ((mediaSource.supportsTranscoding ?? false) && mediaSource.transcodingUrl != null) {
@@ -252,6 +256,11 @@ class PlaybackModelHelper {
252256
}
253257
}
254258

259+
String? isValidVideoUrl(String path) {
260+
Uri? uri = Uri.tryParse(path);
261+
return (uri != null && uri.hasScheme && uri.hasAuthority) ? path : null;
262+
}
263+
255264
Future<List<ItemBaseModel>> collectQueue(ItemBaseModel model) async {
256265
switch (model) {
257266
case EpisodeModel _:

0 commit comments

Comments
 (0)