androidandroid-jetpack-composeandroid-media3

Does Media3 support playing video from a byte array?


I'm developing an app that uses the SMB protocol to remotely view images and videos. Since I'm using Jetpack for UI development, I prefer using Media3 for video playback.

When reading video files via SMB, I cannot load an entire file into memory at once. Therefore, I plan to load the video in segments into a byte array and have Media3 play it. Is this approach feasible? Does Media3 provide support for streaming or playing video data directly from a byte array (or a custom buffer)? If so, could you point me to relevant documentation or examples? If not, what would be the recommended way to handle large remote video files efficiently with Media3?


Solution

  • You likely need a custom data source.
    Here are some examples:
    https://juliensalvi.medium.com/building-custom-datasource-for-exoplayer-87fd16c71950

    https://github.com/sentinelweb/LanTV/blob/master/tvmod/src/main/java/uk/co/sentinelweb/tvmod/exoplayer/upstream/SmbDataSource.java