A music player that connects to your cloud/distributed storage.
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fixes #428

+54 -43
+54 -43
src/Core/UI/Audio/State.elm
··· 27 27 durationChange { trackId, duration } = 28 28 onlyIfMatchesNowPlaying 29 29 { trackId = trackId } 30 - (\nowPlaying model -> 31 - let 32 - ( identifiers, track ) = 33 - nowPlaying.item.identifiedTrack 30 + (\nowPlaying -> 31 + case nowPlaying.duration of 32 + Nothing -> 33 + durationChange_ { trackId = trackId, duration = duration } nowPlaying 34 + 35 + Just _ -> 36 + -- Ignore repeating events 37 + Return.singleton 38 + ) 39 + 40 + 41 + durationChange_ : DurationChangeEvent -> NowPlaying -> Manager 42 + durationChange_ { trackId, duration } nowPlaying model = 43 + let 44 + ( identifiers, track ) = 45 + nowPlaying.item.identifiedTrack 34 46 35 - maybeCover = 36 - List.find 37 - (\c -> List.member trackId c.trackIds) 38 - model.covers.arranged 47 + maybeCover = 48 + List.find 49 + (\c -> List.member trackId c.trackIds) 50 + model.covers.arranged 39 51 40 - coverPrep = 41 - Maybe.map 42 - (\cover -> 43 - { cacheKey = Base64.encode (Tracks.coverKey cover.variousArtists track) 44 - , trackFilename = identifiers.filename 45 - , trackPath = track.path 46 - , trackSourceId = track.sourceId 47 - , variousArtists = boolToString cover.variousArtists 48 - } 49 - ) 50 - maybeCover 52 + coverPrep = 53 + Maybe.map 54 + (\cover -> 55 + { cacheKey = Base64.encode (Tracks.coverKey cover.variousArtists track) 56 + , trackFilename = identifiers.filename 57 + , trackPath = track.path 58 + , trackSourceId = track.sourceId 59 + , variousArtists = boolToString cover.variousArtists 60 + } 61 + ) 62 + maybeCover 51 63 52 - coverLoaded = 53 - case ( maybeCover, model.cachedCovers ) of 54 - ( Just cover, Just cachedCovers ) -> 55 - let 56 - key = 57 - Base64.encode (Tracks.coverKey cover.variousArtists track) 58 - in 59 - Dict.member key cachedCovers 64 + coverLoaded = 65 + case ( maybeCover, model.cachedCovers ) of 66 + ( Just cover, Just cachedCovers ) -> 67 + let 68 + key = 69 + Base64.encode (Tracks.coverKey cover.variousArtists track) 70 + in 71 + Dict.member key cachedCovers 60 72 61 - _ -> 62 - False 73 + _ -> 74 + False 63 75 64 - metadata = 65 - { album = track.tags.album 66 - , artist = track.tags.artist 67 - , title = track.tags.title 76 + metadata = 77 + { album = track.tags.album 78 + , artist = track.tags.artist 79 + , title = track.tags.title 68 80 69 - -- 70 - , coverPrep = coverPrep 71 - } 72 - in 73 - model 74 - |> replaceNowPlaying { nowPlaying | coverLoaded = coverLoaded, duration = Just duration } 75 - |> Return.command (Ports.setMediaSessionMetadata metadata) 76 - |> Return.command (Ports.resetScrobbleTimer { duration = duration, trackId = trackId }) 77 - |> Return.andThen (notifyScrobblersOfTrackPlaying { duration = duration }) 78 - ) 81 + -- 82 + , coverPrep = coverPrep 83 + } 84 + in 85 + model 86 + |> replaceNowPlaying { nowPlaying | coverLoaded = coverLoaded, duration = Just duration } 87 + |> Return.command (Ports.setMediaSessionMetadata metadata) 88 + |> Return.command (Ports.resetScrobbleTimer { duration = duration, trackId = trackId }) 89 + |> Return.andThen (notifyScrobblersOfTrackPlaying { duration = duration }) 79 90 80 91 81 92 error : ErrorAudioEvent -> Manager