Gary
Gary

Reputation: 2266

Android WebView Disable <Audio> Tag

My Android WebView is loading a 3rd party URL.

I.e.http://www.desiringgod.org/resource-library/sermons/gods-good-news-concerning-his-son

It works great, however because of the tag which gets loaded through javascript, the WebView begins downloading the mp3 without user input as soon as the page loads.

I have tried calling WebView.stopLoading() once progress has finished, as well as shouldOverrideUrlLoading(WebView view, String url) to try to catch ending with ".mp3" but it doesn't seem to be able to able to stop it!

My main concern is the amount of data it automatically downloads, if there's any way to stop the download or replace the tags before the page loads that would be great.

Thanks!

UPDATE: actually I found the reason the Audio tags were loading without user prompt is because it is using flash. Once I enabled plugins on webview it stops downloading by itself. However I will still be interested to know how to stop tags within webviews in Android downloading data in background without user knowledge!

Upvotes: 2

Views: 1546

Answers (1)

Ian Devlin
Ian Devlin

Reputation: 18870

I don't know WebView itself, but if the audio tag is being used, you can ask the browser to not download the audio file by setting the preload attribute to none.

Upvotes: 1

Related Questions