mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00

* refactor: remove SourcedTrack based audio player and utilize mediakit playback system * feat: implement local (loopback) server to resolve stream source and leverage the media_kit playback API * feat: add source change support and re-add prefetching tracks * fix: assign lastId when track fetch completes regardless of error * chore: remove print statements * fix: remote queue not working * fix: increase mpv network timeout to reduce auto-skipping * fix: do not pre-fetch local tracks * fix(proxy-playlist): reset collections on load * chore: fix lint warnings * fix(mobile): player overlay should not be visible when the player is not playing * chore: fix typo in turkish translation * cd: checkout PR branch * cd: upgrade flutter version * chore: fix lint errors
58 lines
1.2 KiB
Dart
58 lines
1.2 KiB
Dart
import 'package:catcher_2/catcher_2.dart';
|
|
|
|
/// Parses duration string formatted by Duration.toString() to [Duration].
|
|
/// The string should be of form hours:minutes:seconds.microseconds
|
|
///
|
|
/// Example:
|
|
/// parseTime('245:09:08.007006');
|
|
Duration parseDuration(String input) {
|
|
final parts = input.split(':');
|
|
|
|
if (parts.length != 3) throw const FormatException('Invalid time format');
|
|
|
|
int days;
|
|
int hours;
|
|
int minutes;
|
|
int seconds;
|
|
int milliseconds;
|
|
int microseconds;
|
|
|
|
{
|
|
final p = parts[2].split('.');
|
|
|
|
if (p.length != 2) throw const FormatException('Invalid time format');
|
|
|
|
final p2 = int.parse(p[1]);
|
|
microseconds = p2 % 1000;
|
|
milliseconds = p2 ~/ 1000;
|
|
|
|
seconds = int.parse(p[0]);
|
|
}
|
|
|
|
minutes = int.parse(parts[1]);
|
|
|
|
{
|
|
int p = int.parse(parts[0]);
|
|
hours = p % 24;
|
|
days = p ~/ 24;
|
|
}
|
|
|
|
return Duration(
|
|
days: days,
|
|
hours: hours,
|
|
minutes: minutes,
|
|
seconds: seconds,
|
|
milliseconds: milliseconds,
|
|
microseconds: microseconds,
|
|
);
|
|
}
|
|
|
|
Duration? tryParseDuration(String input) {
|
|
try {
|
|
return parseDuration(input);
|
|
} catch (e, stack) {
|
|
Catcher2.reportCheckedError(e, stack);
|
|
return null;
|
|
}
|
|
}
|