How to stop media playback on a UIWebView
A number of apps, including Twitter for iPhone, don't stop media playback in embedded browsers when hiding them. Here's how to fix that.
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.
The How to stop media playback on a UIWebView article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.A number of apps, including Twitter for iPhone, don't stop media playback in embedded browsers when hiding them. Here's how to fix that.
Thank you very much! Gorgeous Method! You are guru!
I spended 3 hours to stop youtube movie of UIWebView for iPad gallery app. “StopLoading”, “Releasing” didn’t stop playing video.
Thank you!