Skip to content

Commit

Permalink
Merge pull request #128 from tidal-music/alberto/offlineengine-suppor…
Browse files Browse the repository at this point in the history
…t-offlineplay

[Player] Support OfflinePlay event in OfflineEngine items
  • Loading branch information
asendra authored Oct 23, 2024
2 parents 22f4bca + fc83488 commit 4a87b1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Sources/Player/PlaybackEngine/Internal/PlaybackSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ enum PlaybackSource {
case INTERNET
case LOCAL_STORAGE
case LOCAL_STORAGE_LEGACY

func isOfflineSource() -> Bool {
switch self {
case .LOCAL_STORAGE, .LOCAL_STORAGE_LEGACY:
true
case .INTERNET:
false
}
}
}
7 changes: 4 additions & 3 deletions Sources/Player/PlaybackEngine/Internal/PlayerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,12 @@ private extension PlayerItem {

func emitOfflinePlay() {
guard let metrics,
metrics.actualStartTime != nil,
let metadata,
metadata.playbackSource.isOfflineSource(),
let playbackContext,
let asset,
let productId = Int(playbackContext.productId),
metrics.actualStartTime != nil,
mediaProduct is StoredMediaProduct
let asset
else {
return
}
Expand Down

0 comments on commit 4a87b1b

Please sign in to comment.