mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
chore: Play BigBuckBunny for every fake item (#243)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
3ca3d72b9c
commit
485de0d7b4
4 changed files with 110 additions and 36 deletions
|
|
@ -641,6 +641,44 @@ class FakeJellyfinOpenApi extends JellyfinOpenApi {
|
||||||
const BaseItemDtoQueryResult(),
|
const BaseItemDtoQueryResult(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<chopper.Response<PlaybackInfoResponse>> itemsItemIdPlaybackInfoPost({
|
||||||
|
required String? itemId,
|
||||||
|
String? userId,
|
||||||
|
int? maxStreamingBitrate,
|
||||||
|
int? startTimeTicks,
|
||||||
|
int? audioStreamIndex,
|
||||||
|
int? subtitleStreamIndex,
|
||||||
|
int? maxAudioChannels,
|
||||||
|
String? mediaSourceId,
|
||||||
|
String? liveStreamId,
|
||||||
|
bool? autoOpenLiveStream,
|
||||||
|
bool? enableDirectPlay,
|
||||||
|
bool? enableDirectStream,
|
||||||
|
bool? enableTranscoding,
|
||||||
|
bool? allowVideoStreamCopy,
|
||||||
|
bool? allowAudioStreamCopy,
|
||||||
|
required PlaybackInfoDto? body,
|
||||||
|
}) async {
|
||||||
|
return chopper.Response(
|
||||||
|
FakeHelper.fakeCorrectResponse,
|
||||||
|
FakeHelper.bigBuckBunny,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<chopper.Response<MediaSegmentDtoQueryResult>> mediaSegmentsItemIdGet({
|
||||||
|
required String? itemId,
|
||||||
|
List<enums.MediaSegmentType>? includeSegmentTypes,
|
||||||
|
}) async {
|
||||||
|
return chopper.Response(
|
||||||
|
FakeHelper.fakeCorrectResponse,
|
||||||
|
const MediaSegmentDtoQueryResult(
|
||||||
|
items: [],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeHelper {
|
class FakeHelper {
|
||||||
|
|
@ -700,4 +738,30 @@ class FakeHelper {
|
||||||
accessToken: 'A_TOTALLY_REAL_TOKEN',
|
accessToken: 'A_TOTALLY_REAL_TOKEN',
|
||||||
serverId: "1",
|
serverId: "1",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static PlaybackInfoResponse bigBuckBunny = PlaybackInfoResponse.fromJson({
|
||||||
|
"MediaSources": [
|
||||||
|
{
|
||||||
|
"Protocol": "File",
|
||||||
|
"Id": "234sdfsdf234",
|
||||||
|
"Path": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
|
||||||
|
"Type": "Default",
|
||||||
|
"Container": "mkv",
|
||||||
|
"Size": 513949601,
|
||||||
|
"Name": "Big Buck Bunny",
|
||||||
|
"IsRemote": false,
|
||||||
|
"ETag": "sdfsdfsd",
|
||||||
|
"RunTimeTicks": 26540060000,
|
||||||
|
"SupportsTranscoding": false,
|
||||||
|
"SupportsDirectStream": true,
|
||||||
|
"SupportsDirectPlay": true,
|
||||||
|
"VideoType": "VideoFile",
|
||||||
|
"MediaAttachments": [],
|
||||||
|
"Formats": [],
|
||||||
|
"Bitrate": 1741204,
|
||||||
|
"HasSegments": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PlaySessionId": "asdf234qwafsdfsdf"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,8 +190,8 @@ class PlaybackModelHelper {
|
||||||
Map<Bitrate, bool> qualityOptions = getVideoQualityOptions(
|
Map<Bitrate, bool> qualityOptions = getVideoQualityOptions(
|
||||||
VideoQualitySettings(
|
VideoQualitySettings(
|
||||||
maxBitRate: ref.read(videoPlayerSettingsProvider.select((value) => value.maxHomeBitrate)),
|
maxBitRate: ref.read(videoPlayerSettingsProvider.select((value) => value.maxHomeBitrate)),
|
||||||
videoBitRate: firstItemToPlay.streamModel?.videoStreams.first.bitRate ?? 0,
|
videoBitRate: firstItemToPlay.streamModel?.videoStreams.firstOrNull?.bitRate ?? 0,
|
||||||
videoCodec: firstItemToPlay.streamModel?.videoStreams.first.codec,
|
videoCodec: firstItemToPlay.streamModel?.videoStreams.firstOrNull?.codec,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -215,9 +215,12 @@ class PlaybackModelHelper {
|
||||||
);
|
);
|
||||||
|
|
||||||
PlaybackInfoResponse? playbackInfo = response.body;
|
PlaybackInfoResponse? playbackInfo = response.body;
|
||||||
|
|
||||||
if (playbackInfo == null) return null;
|
if (playbackInfo == null) return null;
|
||||||
|
|
||||||
final mediaSource = playbackInfo.mediaSources?.first;
|
final mediaSource = playbackInfo.mediaSources?[streamModel?.versionStreamIndex ?? 0];
|
||||||
|
|
||||||
|
if (mediaSource == null) return null;
|
||||||
|
|
||||||
final mediaStreamsWithUrls = MediaStreamsModel.fromMediaStreamsList(playbackInfo.mediaSources, ref).copyWith(
|
final mediaStreamsWithUrls = MediaStreamsModel.fromMediaStreamsList(playbackInfo.mediaSources, ref).copyWith(
|
||||||
defaultAudioStreamIndex: streamModel?.defaultAudioStreamIndex,
|
defaultAudioStreamIndex: streamModel?.defaultAudioStreamIndex,
|
||||||
|
|
@ -228,9 +231,7 @@ class PlaybackModelHelper {
|
||||||
final trickPlay = (await api.getTrickPlay(item: fullItem.body, ref: ref))?.body;
|
final trickPlay = (await api.getTrickPlay(item: fullItem.body, ref: ref))?.body;
|
||||||
final chapters = fullItem.body?.overview.chapters ?? [];
|
final chapters = fullItem.body?.overview.chapters ?? [];
|
||||||
|
|
||||||
final mediaPath = isValidVideoUrl(mediaSource?.path ?? "");
|
final mediaPath = isValidVideoUrl(mediaSource.path ?? "");
|
||||||
|
|
||||||
if (mediaSource == null) return null;
|
|
||||||
|
|
||||||
if ((mediaSource.supportsDirectStream ?? false) || (mediaSource.supportsDirectPlay ?? false)) {
|
if ((mediaSource.supportsDirectStream ?? false) || (mediaSource.supportsDirectPlay ?? false)) {
|
||||||
final Map<String, String?> directOptions = {
|
final Map<String, String?> directOptions = {
|
||||||
|
|
@ -271,6 +272,7 @@ class PlaybackModelHelper {
|
||||||
playbackInfo: playbackInfo,
|
playbackInfo: playbackInfo,
|
||||||
media: Media(url: "${ref.read(userProvider)?.server ?? ""}${mediaSource.transcodingUrl ?? ""}"),
|
media: Media(url: "${ref.read(userProvider)?.server ?? ""}${mediaSource.transcodingUrl ?? ""}"),
|
||||||
mediaStreams: mediaStreamsWithUrls,
|
mediaStreams: mediaStreamsWithUrls,
|
||||||
|
bitRateOptions: qualityOptions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
@ -49,6 +51,7 @@ class VideoQualitySettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<Bitrate, bool> getVideoQualityOptions(VideoQualitySettings options) {
|
Map<Bitrate, bool> getVideoQualityOptions(VideoQualitySettings options) {
|
||||||
|
try {
|
||||||
final maxStreamingBitrate = options.maxBitRate;
|
final maxStreamingBitrate = options.maxBitRate;
|
||||||
final videoBitRate = options.videoBitRate;
|
final videoBitRate = options.videoBitRate;
|
||||||
final videoCodec = options.videoCodec;
|
final videoCodec = options.videoCodec;
|
||||||
|
|
@ -76,8 +79,8 @@ Map<Bitrate, bool> getVideoQualityOptions(VideoQualitySettings options) {
|
||||||
Bitrate? selectedQualityOption;
|
Bitrate? selectedQualityOption;
|
||||||
if (maxStreamingBitrate != null && maxStreamingBitrate != Bitrate.original) {
|
if (maxStreamingBitrate != null && maxStreamingBitrate != Bitrate.original) {
|
||||||
selectedQualityOption = qualityOptions
|
selectedQualityOption = qualityOptions
|
||||||
.where(
|
.where((value) =>
|
||||||
(value) => value.calculatedBitRate > 0 && value.calculatedBitRate <= maxStreamingBitrate.calculatedBitRate)
|
value.calculatedBitRate > 0 && value.calculatedBitRate <= maxStreamingBitrate.calculatedBitRate)
|
||||||
.firstOrNull;
|
.firstOrNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,4 +90,8 @@ Map<Bitrate, bool> getVideoQualityOptions(VideoQualitySettings options) {
|
||||||
bitrate == maxStreamingBitrate || bitrate == selectedQualityOption,
|
bitrate == maxStreamingBitrate || bitrate == selectedQualityOption,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
log(e.toString());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue