Menu

Playback failures as typed causes: retry, hand over or stop
📰

Playback failures as typed causes: retry, hand over or stop

DEV Community: kotlin·Yonto Player·2 days ago
#HBmNNqRd
#devtokotlin#devto#dev#player#cause
Long article (1249 words) — no AI summary yet.
Reading 0:00
15s threshold

A video player is told "playback failed" in many ways, and from the outside they look alike: the picture is gone. The wifi dropped for a moment. The file is in a format the first player cannot read. The server answered, but not with a stream. One audio track has no decoder on this device.

What the app should do next differs each time. Ask for the stream again and carry on from where it stopped. Hand the file to another player. Or stop and tell the viewer in plain words.

In Yonto Player this is one design decision: a failure is a value that names its cause, and it is never just a message string. Retry and hand-over decisions read the cause. This post is about that type and the small pieces of code that read it. (A normal end of playback is not a failure; it is a state of its own and stays out of this.)

Why not branch on the message

The obvious way is to catch an error from the player, look at its message or error code, and branch.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.