DEV Community

saca killer
saca killer

Posted on

# How I Built a Zero-Buffer NAS Media Player in Flutter (and Fought AI Hallucinations Along the Way)

If you are a Datahoarder or HomeLab enthusiast with a massive NAS setup, you probably know this pain:
Official NAS apps (like DS Video) are often sluggish. Indexing takes forever. You wait for the buffering spinner every time you try to play a high-bitrate MKV file. And if you want to read a comic archive (ZIP/CBZ), you usually have to download and extract the whole thing first.

While iOS has some great premium options, the Android and Amazon Fire TV ecosystems severely lacked a "no-BS, instant-play" solution.

So, I decided to build one myself using Flutter.
Here is the technical breakdown of how I hacked together Nas Player Pro—achieving zero-buffer video streaming and network-direct ZIP reading, all while wrestling with an AI assistant.

1. Hacking SMB Streaming: The Local Proxy Buffer

The first wall I hit was streaming massive video files over the SMB protocol.
Passing an smb:// path directly to standard Flutter media players resulted in terrible latency and constant buffering during seeks.

My AI coding assistant suggested an interesting architecture: Build a local HTTP proxy server.

The Implementation:

  1. Spin up a lightweight HTTP server inside the app (localhost).
  2. Feed the video player a local URL like http://localhost:port/stream.
  3. The proxy server intercepts the Range requests from the video player.
  4. It translates those requests into SMB client calls, fetching only the exact byte ranges from the NAS, and piping them back to the player.

By injecting this proxy buffer layer, playing a 30GB TS or MKV file over the local network became as instant as opening a local file. Zero buffering, instant seeking. The AI’s architectural advice was spot on.

2. Reading ZIP/RAR Over the Network (Without Extracting)

The next challenge was native comic reading. I wanted to open ZIP, RAR, CBZ, and CBR archives directly over the network without downloading them.

When I asked the AI to write this, it failed miserably. It hallucinated non-existent streaming libraries or secretly wrote code that downloaded the entire file into the cache first.

Realizing I had to do this myself, I dug into the binary format specifications of ZIP and RAR files.

The Hack:
ZIP files contain an "End of central directory record" at the very end of the file. This acts as a table of contents.

  1. Read the Tail: Using SMB random access, I fetch only the last few kilobytes of the ZIP file over the network.
  2. Parse the Directory: I decode the binary to find out exactly at what Offset and with what Compressed Size each image (jpg/png) is stored inside the archive.
  3. Extract on the Fly: When the user swipes to page 3, the app uses SMB Range Requests to pull only those specific bytes from the NAS, decodes the image in memory, and renders it.

This allowed the app to open massive comic archives instantly over the network, pulling only the data it needs frame by frame.

3. The Reality of "Vibecoding"

Building this was a constant battle with the AI.
Once I figured out the ZIP binary header logic, I had the AI write the boilerplate Dart ByteData operations. But AI has the memory of a goldfish.

While asking it to fix a minor UI bug, it would often decide to "refactor" my code—silently deleting my complex byte-parsing logic without warning.
Since I was still getting the hang of Git, I resorted to a manual survival tactic: duplicating my project folder (backup_before_ai_touch) every 30 minutes. It was less like "AI generating an app" and more like "wrestling a brilliant but chaotic intern who randomly deletes production code."

Conclusion

Despite the chaos, the result is a highly optimized, cross-platform (Android, iOS, Amazon Fire) SMB utility built strictly for power users.

If you are tired of bloated server-side setups and just want to access your NAS media at lightning speed, feel free to check out the result of this battle:

🚀 Nas Player Pro (App Store, Google Play, Amazon Fire)

I’d love to hear your thoughts, especially if you've tackled SMB streaming or binary parsing in Dart!

Top comments (0)