mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 13:38:13 -08:00
fix: Bitrate display in Media Info (#556)
This commit is contained in:
parent
b9c1e82b43
commit
2594a8463f
2 changed files with 27 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
// ignore_for_file: constant_identifier_names
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
|
import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
|
||||||
|
import 'package:fladder/util/bitrate_formatting.dart';
|
||||||
import 'package:fladder/util/size_formatting.dart';
|
import 'package:fladder/util/size_formatting.dart';
|
||||||
|
|
||||||
class InformationModel {
|
class InformationModel {
|
||||||
|
|
@ -35,10 +36,10 @@ class InformationModel {
|
||||||
"Profile": e.profile,
|
"Profile": e.profile,
|
||||||
"Level": e.level,
|
"Level": e.level,
|
||||||
"Resolution": "${e.width}x${e.height}",
|
"Resolution": "${e.width}x${e.height}",
|
||||||
"Aspect Ration": e.aspectRatio,
|
"Aspect Ratio": e.aspectRatio,
|
||||||
"Interlaced": e.isInterlaced,
|
"Interlaced": e.isInterlaced,
|
||||||
"FrameRate": e.realFrameRate,
|
"FrameRate": e.realFrameRate,
|
||||||
"Bitrate": "${e.bitRate} kbps",
|
"Bitrate": e.bitRate.videoBitrateFormat,
|
||||||
"Bit depth": e.bitDepth,
|
"Bit depth": e.bitDepth,
|
||||||
"Video range": e.videoRange,
|
"Video range": e.videoRange,
|
||||||
"Video range type": e.videoRangeType,
|
"Video range type": e.videoRangeType,
|
||||||
|
|
@ -53,7 +54,7 @@ class InformationModel {
|
||||||
"Language": e.language,
|
"Language": e.language,
|
||||||
"Codec": e.codec,
|
"Codec": e.codec,
|
||||||
"Layout": e.channelLayout,
|
"Layout": e.channelLayout,
|
||||||
"Bitrate": "${e.bitRate} kbps",
|
"Bitrate": e.bitRate.audioBitrateFormat,
|
||||||
"Sample Rate": "${e.sampleRate} Hz",
|
"Sample Rate": "${e.sampleRate} Hz",
|
||||||
"Default": e.isDefault,
|
"Default": e.isDefault,
|
||||||
"Forced": e.isForced,
|
"Forced": e.isForced,
|
||||||
|
|
|
||||||
23
lib/util/bitrate_formatting.dart
Normal file
23
lib/util/bitrate_formatting.dart
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
|
extension BitrateFormats on int? {
|
||||||
|
String? get audioBitrateFormat {
|
||||||
|
final bitrate = this;
|
||||||
|
if (bitrate == null) return null;
|
||||||
|
return "${(bitrate / 1000).round()} kbps";
|
||||||
|
}
|
||||||
|
|
||||||
|
String? get videoBitrateFormat {
|
||||||
|
const int highBitrateCutoff = 10000000;
|
||||||
|
const int kb = 1000;
|
||||||
|
const int Mb = kb * kb;
|
||||||
|
|
||||||
|
final bitrate = this;
|
||||||
|
if (bitrate == null) return null;
|
||||||
|
if (bitrate >= highBitrateCutoff) {
|
||||||
|
return "${(bitrate / Mb).toStringAsFixed(1)} Mbps";
|
||||||
|
} else {
|
||||||
|
return "${(bitrate / kb).round()} kbps";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue