Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch errors when reporting playback state #4171

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class ReportingHelper(

lifecycleOwner.lifecycleScope.launch {
Timber.i("Reporting ${item.name} playback started at $position")
api.playStateApi.reportPlaybackStart(info)
runCatching {
api.playStateApi.reportPlaybackStart(info)
}.onFailure { error -> Timber.e(error, "Failed to report started playback!") }
}
}

Expand Down Expand Up @@ -87,7 +89,9 @@ class ReportingHelper(

lifecycleOwner.lifecycleScope.launch {
Timber.d("Reporting ${item.name} playback progress at $position")
api.playStateApi.reportPlaybackProgress(info)
runCatching {
api.playStateApi.reportPlaybackProgress(info)
}.onFailure { error -> Timber.w(error, "Failed to report playback progress") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't as excited as the others

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, if the start/stop fails it can screw with activity / playback reporting etc. A missed progress update can be easily recovered with the next update.

}
}

Expand All @@ -103,7 +107,9 @@ class ReportingHelper(

lifecycleOwner.lifecycleScope.launch {
Timber.i("Reporting ${item.name} playback stopped at $position")
api.playStateApi.reportPlaybackStopped(info)
runCatching {
api.playStateApi.reportPlaybackStopped(info)
}.onFailure { error -> Timber.e(error, "Failed to report stopped playback!") }
}

// Update dataRefreshService
Expand Down
Loading