mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-22 09:58:46 -05:00
maybe if I tell it we've listened to the whole track?
This commit is contained in:
+3
-6
@@ -1,6 +1,7 @@
|
||||
import { Progress, State } from "react-native-track-player";
|
||||
import { JellifyTrack } from "../types/JellifyTrack";
|
||||
import { PlaystateApi } from "@jellyfin/sdk/lib/generated-client/api/playstate-api";
|
||||
import { convertSecondsToRunTimeTicks } from "@/helpers/runtimeticks";
|
||||
|
||||
export async function handlePlaybackState(sessionId: string, playstateApi: PlaystateApi, track: JellifyTrack, state: State) {
|
||||
switch (state) {
|
||||
@@ -57,17 +58,13 @@ export async function handlePlaybackStarted(sessionId: string, playstateApi: Pla
|
||||
}
|
||||
|
||||
export async function handlePlaybackProgressUpdated(sessionId: string, playstateApi: PlaystateApi, track: JellifyTrack, progress: Progress) {
|
||||
|
||||
console.debug("Progress updated:", progress);
|
||||
|
||||
console.debug(Math.floor(progress.duration - progress.position))
|
||||
|
||||
if (Math.floor(progress.duration - progress.position) === 5) {
|
||||
console.debug("Track finished, scrobbling...");
|
||||
await playstateApi.reportPlaybackStopped({
|
||||
playbackStopInfo: {
|
||||
SessionId: sessionId,
|
||||
ItemId: track.ItemId
|
||||
ItemId: track.ItemId,
|
||||
PositionTicks: convertSecondsToRunTimeTicks(track.duration!)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user