Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select transcoding segment container, default to fmp4 #915

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,11 @@
},
"description": "Localized names of special downloadable collection representing cached images for a certain library."
},
"transcodingStreamingContainerTitle": "Select Transcoding Container",
"@transcodingStreamingContainerTitle": {
"description": "Title for the dropdown that selects the container format for transcoded streams"
},
"transcodingStreamingContainerSubtitle": "Select the segment container to use when streaming transcoded audio. Already queued tracks will not be affected.",
"downloadTranscodeEnableTitle": "Enable Transcoded Downloads",
"@downloadTranscodeEnableTitle": {
"description": "Title for Enable Transcoded Downloads dropdown"
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Future<void> setupHive() async {
Hive.registerAdapter(LyricsAlignmentAdapter());
Hive.registerAdapter(LyricsFontSizeAdapter());
Hive.registerAdapter(KeepScreenOnOptionAdapter());
Hive.registerAdapter(FinampSegmentContainerAdapter());
Hive.registerAdapter(FinampFeatureChipsConfigurationAdapter());
Hive.registerAdapter(FinampFeatureChipTypeAdapter());

Expand Down
23 changes: 21 additions & 2 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const _showStopButtonOnMediaNotificationDefault = false;
const _showSeekControlsOnMediaNotificationDefault = true;
const _keepScreenOnOption = KeepScreenOnOption.whileLyrics;
const _keepScreenOnWhilePluggedIn = true;
const _defaultTranscodingSegmentContainer =
FinampSegmentContainer.fragmentedMp4;
const _featureChipsConfigurationDefault =
FinampFeatureChipsConfiguration(enabled: true, features: [
FinampFeatureChipType.playCount,
Expand Down Expand Up @@ -209,6 +211,7 @@ class FinampSettings {
_showSeekControlsOnMediaNotificationDefault,
this.keepScreenOnOption = _keepScreenOnOption,
this.keepScreenOnWhilePluggedIn = _keepScreenOnWhilePluggedIn,
this.transcodingSegmentContainer = _defaultTranscodingSegmentContainer,
this.featureChipsConfiguration = _featureChipsConfigurationDefault});

@HiveField(0, defaultValue: _isOfflineDefault)
Expand Down Expand Up @@ -446,7 +449,10 @@ class FinampSettings {
@HiveField(73, defaultValue: _keepScreenOnWhilePluggedIn)
bool keepScreenOnWhilePluggedIn;

@HiveField(74, defaultValue: _featureChipsConfigurationDefault)
@HiveField(74, defaultValue: _defaultTranscodingSegmentContainer)
FinampSegmentContainer transcodingSegmentContainer;

@HiveField(75, defaultValue: _featureChipsConfigurationDefault)
FinampFeatureChipsConfiguration featureChipsConfiguration;

static Future<FinampSettings> create() async {
Expand Down Expand Up @@ -2252,6 +2258,19 @@ enum KeepScreenOnOption {
}

@HiveType(typeId: 73)
enum FinampSegmentContainer {
@HiveField(0)
mpegTS("ts"),
@HiveField(1)
fragmentedMp4("mp4");

const FinampSegmentContainer(this.container);

/// The container to use to transport the segments
final String container;
}

@HiveType(typeId: 74)
enum FinampFeatureChipType {
@HiveField(0)
playCount,
Expand Down Expand Up @@ -2329,7 +2348,7 @@ enum FinampFeatureChipType {
}

@JsonSerializable()
@HiveType(typeId: 74)
@HiveType(typeId: 75)
class FinampFeatureChipsConfiguration {
const FinampFeatureChipsConfiguration({
required this.enabled,
Expand Down
55 changes: 50 additions & 5 deletions lib/models/finamp_models.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions lib/screens/transcoding_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TranscodingSettingsScreen extends StatelessWidget {
children: [
const TranscodeSwitch(),
const BitrateSelector(),
const StreamingTranscodeSegmentContainerDropdownListTile(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
Expand Down Expand Up @@ -165,3 +166,42 @@ class DownloadTranscodeCodecDropdownListTile extends StatelessWidget {
);
}
}

class StreamingTranscodeSegmentContainerDropdownListTile
extends StatelessWidget {
const StreamingTranscodeSegmentContainerDropdownListTile({super.key});

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<Box<FinampSettings>>(
valueListenable: FinampSettingsHelper.finampSettingsListener,
builder: (_, box, __) {
final finampSettings = box.get("FinampSettings")!;

return ListTile(
title: Text(
AppLocalizations.of(context)!.transcodingStreamingContainerTitle),
subtitle: Text(AppLocalizations.of(context)!
.transcodingStreamingContainerSubtitle),
trailing: DropdownButton<FinampSegmentContainer>(
value: finampSettings.transcodingSegmentContainer,
items: FinampSegmentContainer.values
.map((e) => DropdownMenuItem<FinampSegmentContainer>(
value: e,
child: Text(e.container!.toUpperCase()),
))
.toList(),
onChanged: (value) {
if (value != null) {
FinampSettings finampSettingsTemp = finampSettings;
finampSettingsTemp.transcodingSegmentContainer = value;
Hive.box<FinampSettings>("FinampSettings")
.put("FinampSettings", finampSettingsTemp);
}
},
),
);
},
);
}
}
3 changes: 2 additions & 1 deletion lib/services/queue_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,8 @@ class QueueService {
"maxAudioBitDepth": "16",
"audioBitRate":
FinampSettingsHelper.finampSettings.transcodeBitrate.toString(),
"segmentContainer": "ts",
"segmentContainer": FinampSettingsHelper
.finampSettings.transcodingSegmentContainer.container,
"transcodeReasons": "ContainerBitrateExceedsLimit",
});
} else {
Expand Down