Can I use the Android SDK to download videos from a source that has no internet access?

Hi @andrew.mccaughan

Thank you for posting your findings.

One of my colleagues and I did independent tests yesterday, and came to the same conclusion as to why the download fails. Additionally my colleague was able to also provide a workaround, which hopefully also helps within your application.

Network setup
Setup a local HTTP server(Ngnix) on Mac connected to Wifi network at my home
Android phone connected to same Wifi network as Mac
Removed the network cable from Wifi router.
This should mimic the setup for your system/application.

Test
Downloaded and hosted Art of Motion progressive MP4 file on the Nginx HTTP server setup on Mac
On Android device installed the Offline sample application and attempted download.
The Offline sample app sent a license request to license.bitmovin.com and the download does not start until this request is in progress. I confirmed from code that for offline download, Bitmovin SDK wait for request to either succeed or fail before starting download.
The license request fails with HTTP 503 after some time as DNS for license.bitmovin.com could not be resolved.
The download is started after license request fails but it gets stuck at 0%
It does not progress even after a long wait.

Root Cause
Bitmovin download is based on Exo player downloader which allows applications to set some requirements which govern when the download is allowed and when not. Seem that Requirements.Network is the default configuration which expects internet access for download to start.

Solution
Good news is that this is configurable using OfflineConfig.requirements field. After setting it as empty using following code in OnCreate method of MainActivity the offline sample application works. Please see sample code below.

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // set OfflineConfig.requirements as empty to
        // allow download in local network when no internet
        val offlineConfig = OfflineConfig()
        offlineConfig.requirements = Requirements(0)
        OfflineContentManager.setOfflineConfig(this, offlineConfig)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
}

I hope this helps.

2 Likes