即使UIWebView关闭,视频/音频流也不会停止 - iPad [英] Video/audio streaming does not stop even if UIWebView is closed - iPad

查看:106
本文介绍了即使UIWebView关闭,视频/音频流也不会停止 - iPad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只在iPad上看到这个问题。同样的事情在iPhone上运行正常。

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

我在UIWebView中打开我的应用程序的URL。如果URL是普通网页,它可以正常工作。但是如果URL是远程视频/音频文件的URL,则UIWebView会打开默认播放器,这也是好的。

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.

现在当我关闭UIWebView时(通过点击播放器上的完成按钮),流媒体不会停止,音频/视频继续在后台播放(我看不到它,但它确实在后台播放,可以听到它)。创建webview的UIViewController也被解除分配(我在dealloc方法中放入了一个日志语句)但是流式传输没有停止。

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.

有人可以帮助吗我知道为什么会发生这种情况?当UIWebView关闭时,如何停止音频/视频流?

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?

谢谢。

推荐答案

我有同样的问题,但在这种情况下,不会停止播放的视频是使用object / embed方法嵌入的Youtube视频。

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.

我花了很长时间试图弄清楚如何让视频停止播放,我找到的唯一解决方案是告诉UIWebView在解除之前加载空白页面视图:

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")];

编辑(2015-05-12):如下面@chibimai所述,这个回答是由alloc_iNit沿着同样的方向运行但是因为我的回答来自5年前 - 而他的唯一4回答 - 链接的答案可能是更适用。我不再做iPhone开发工作,所以我无法确定哪种方式更好。

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.

这篇关于即使UIWebView关闭,视频/音频流也不会停止 - iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆