mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix(playback): not skipping track's sponsorblock segments
This commit is contained in:
parent
2ebcbc4cea
commit
60a5847ae6
@ -140,7 +140,7 @@ extension GetSkipSegments on Video {
|
|||||||
return List.castFrom<dynamic, Map<String, int>>([]);
|
return List.castFrom<dynamic, Map<String, int>>([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
final data = jsonDecode(res.body);
|
final data = jsonDecode(res.body) as List;
|
||||||
final segments = data.map((obj) {
|
final segments = data.map((obj) {
|
||||||
return Map.castFrom<String, dynamic, String, int>({
|
return Map.castFrom<String, dynamic, String, int>({
|
||||||
"start": obj["segment"].first.toInt(),
|
"start": obj["segment"].first.toInt(),
|
||||||
|
@ -188,6 +188,19 @@ class PlaylistQueueNotifier extends PersistedStateNotifier<PlaylistQueue?> {
|
|||||||
await linuxService?.player.updateProperties();
|
await linuxService?.player.updateProperties();
|
||||||
final currentDuration = await audioPlayer.getDuration() ?? Duration.zero;
|
final currentDuration = await audioPlayer.getDuration() ?? Duration.zero;
|
||||||
|
|
||||||
|
// skip all the activeTrack.skipSegments
|
||||||
|
if (state?.isLoading != true &&
|
||||||
|
(state?.activeTrack as SpotubeTrack).skipSegments.isNotEmpty &&
|
||||||
|
preferences.skipSponsorSegments) {
|
||||||
|
for (final segment
|
||||||
|
in (state!.activeTrack as SpotubeTrack).skipSegments) {
|
||||||
|
if ((pos.inSeconds >= segment["start"]! &&
|
||||||
|
pos.inSeconds < segment["end"]!)) {
|
||||||
|
await audioPlayer.seek(Duration(seconds: segment["end"]!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// when the track progress is above 80%, track isn't the last
|
// when the track progress is above 80%, track isn't the last
|
||||||
// and is not already fetched and nothing is fetching currently
|
// and is not already fetched and nothing is fetching currently
|
||||||
if (pos.inSeconds > currentDuration.inSeconds * .8 &&
|
if (pos.inSeconds > currentDuration.inSeconds * .8 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user