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

查看:35
本文介绍了即使 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天全站免登陆