Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Video/audio streaming does not stop even if UIWebView is closed - iPad

I see this issue only on the iPad. The same things works as expected on the iPhone.

I am opening the URL from my application in a UIWebView. If the URL is a normal web page, it works fine as expected. But if the URL is that of a remote video/audio file, the UIWebView opens the default player which is again good.

Now when I dismiss the UIWebView (by clicking on the Done button on the player), the streaming doesn't stop and the audio/video keeps playing in the background (I cannot see it but it does keep playing in the background, can hear it). The UIViewController in which the webview was created is also dealloced (I put in a log statement in the dealloc method) but the streaming doesn't stop.

Can someone please help me out on why this could be happening? And how can I stop the audio/video streaming when the UIWebView is closed?

Thanks.

like image 806
lostInTransit Avatar asked Apr 27 '10 06:04

lostInTransit


1 Answers

I have the same issue as stated but in this case the video that won't stop playing is a Youtube video embeded using the object/embed method.

I spent a long time trying to figure out how to get the video to stop playing and the only solution I found was to tell the UIWebView to load a blank page before dismissing the view:

    [self.webContent loadRequest:NSURLRequestFromString(@"about:blank")]; 

Edit(2015-05-12): As mentioned by @chibimai below, this answer by alloc_iNit works along the same lines but since my answer is from 5 years ago -- and his only 4 -- the linked answer may be more applicable. I no longer do iPhone dev work so I cannot determine which is better either way.

like image 107
nivekastoreth Avatar answered Sep 18 '22 19:09

nivekastoreth