How to stop media playback on a UIWebView

This morning, Elliot tweeted a link to some instruments for Ableton. I was using Twitter for iPhone so I tapped on the link to open it up in the internal web browser and then proceeded to play the embedded audio in the web page. Half way through, I tapped the back button to get back to my tweets and noticed that the audio kept playing.

The issue is that the UIWebView keeps playing embedded media unless you reset it. But reset how?

I just tested it out and the only way I could get the audio to stop was to load an empty string into the UIWebView like this:

[self.webBrowser loadHTMLString:@"" baseURL:nil];

Things that didn't work include calling the UIWebView's stopLoading method, setting the web view as hidden, removing it from its superview or setting it to nil and/or releasing it.

I've seen this issue with other apps that have embedded UIWebView components so remember folks, reset that web view by loading in an empty string before hiding it to make sure any playing media is stopped.