请原谅我对xcode / ios开发的有限知识。我正在选择一个项目,并在网页加载URL时更改URL,当内容加载URL(包含加载时自动播放的实时流媒体链接)时,如下页面的HTML:
<video id='video_tag' width='1000' height='41' controls="" autoplay="">
<source src='http://domain:ip/;stream.mp3/playlist.m3u8' type='video/mp4'>
<a href='http://domain:ip/;stream.mp3' id='android_firefox' style='display:none;'>Watch this stream over RTSP for Android Mozilla</a><script>if (navigator.userAgent.match(/Android/i) && navigator.userAgent.match(/Firefox/i)) {
document.getElementById('android_firefox').style.display='';document.getElementById('video_tag').style.display = 'none';}
jwplayer.key='xxxxxxxxxxx=';
jwplayer('primcast.com').setup(
{playlist: [{sources:[{file:'http://domain:ip/;stream.mp3'},
{file:'http://domain:ip/;stream.mp3/playlist.m3u8'}]}],
logo: {file: ''},width:1000,height:41,stretching:'undefined',autostart:true,fallback:false,primary:'HTML5',repeat:true});
</script></source></video>
当应用程序在webView中加载它时,屏幕变为空白,但是如果您触摸屏幕,它会尝试播放应用程序上方的音频。屏幕右上方有一个“x”,如果按下,则在调试器中使用以下内容正确返回webView应用程序:
[34780:2737829] WF: _WebFilterIsActive returning: NO
[34780:2737715] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_Presence (client: My App)
[34780:2737715] [framework] CUICatalog: Invalid asset name supplied: '(null)'
[34780:2737715] [framework] CUICatalog: Invalid asset name supplied: '(null)'
[34780:2737715] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None (client: My App)
[34780:2737715] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None (client: My App)
[34780:2737715] [framework] CUICatalog: Invalid asset name supplied: '(null)'
[34780:2737715] [framework] CUICatalog: Invalid asset name supplied: '(null)'
[34780:2737715] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_Presence (client: My App)
[34780:2737715] [] <<<< AVOutputDeviceDiscoverySession (FigRouteDiscoverer) >>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery mode to DiscoveryMode_None (client: My App)
根据我的理解,是自动播放和<video>
标签导致这种行为?
我想,我的问题是,我是否可以通过绕过使App尝试并加载播放器的那部分代码来完全停止这种行为,如果是,如何?
用户不想取消网站上的自动播放功能,因此理想的解决方案是在应用内停止它。
任何帮助,将不胜感激。
我能够解决这个添加这些行
Webview.mediaPlaybackRequiresUserAction=TRUE;
Webview.mediaPlaybackRequiresUserAction = true;
Webview.allowsInlineMediaPlayback = false;