Playing video on Flutter Linux desktop with media_kit
Video is the one media type in tonGues that cannot fail quietly. A photo that won't load falls back to an icon tile and most people never notice; a video that won't play looks like the whole app is broken. So when every video bubble on our Linux desktop build started showing "Video expired" — the label we reserve for a file the server no longer has — we knew something was off. Flutter Linux…
Video playback on the Flutter Linux desktop lacked a player component. When videos failed to play, the app incorrectly displayed "Video expired." The issue arose because the video_player plugin didn't have a Linux implementation, and media_kit wasn't integrated yet. The root cause was simple: VideoPlayerController.initialize() threw UnimplementedError on Linux as there was no backend to handle the video.
The streaming fallback also failed due to the same reason. The solution was to introduce VideoPlaybackController, an abstraction layer between the widget and the player. This controller, which extends ValueNotifier, offered a unified API for both the Linux and other platforms. By implementing MediaKitVideoController for Linux and PluginVideoController for others, the app could seamlessly switch between the two players.
The change required only a few adjustments – creating the appropriate controller based on the platform and rendering the view with buildView(). With this approach, media_kit was integrated without affecting other platforms, and the UI accurately represented the video playback status.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.