为什么HTML5video不能在IOS 8 WebApp(webview)中播放?

简单的HTML5video在Safari浏览器上播放。 但添加到主屏幕(独立WebApp)后,它不起作用。 它正在iOS7上工作,但停止在iOS8上工作。

<!DOCTYPE html> <head> <meta charset="utf-8"> <meta name="apple-mobile-web-app-capable" content="yes" /> <title>HTML5 Video Standalone Test</title> <style> body{ margin:0; } </style> </head> <body> <video src="http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer_480x270_h264aac.m4v" autoplay="autoplay" controls="true" webkit-playsinline /> </body> </html> 

请帮忙。 有没有解决scheme?

video播放在IOS 8.0.2的独立应用程序中被破坏

看起来像iOS 8.3修复了这个问题。 我有一个独立的networking应用程序,使用audio元素,它现在正如预期的那样工作。 最后!

确认

打包的cordova应用程序无法加载video

添加:

 <preference name="AllowInlineMediaPlayback" value="true"/> 

config.xml

 webkit-playsinline 

video元素。

用户界面表示video正在Loading ,而video.networkStatus保持2NETWORK_LOADING )和video.readyState 0HAVE_NOTHING

Safari播放工作

主屏幕启动器播放不起作用

对于在ios Safari中工作的相同web应用程序,主屏幕版本也不播放video,并在尝试更改video源时崩溃web应用程序。

我不喜欢苹果:|

我有两个使用HTML5video的应用程序。 一个停止工作,另一个不工作。 有两个区别:

  • 在将video标签添加到DOM之后,仍然有效的那个将源标签添加到video标签。
  • 仍然有效的应用将自动播放设置为false( <video autoplay="false">...</video>

第一个没有任何区别,第二个使应用程序再次工作。

我想我find了解决方法,audio无法正常工作。 我无法真正解释为什么这个修复工作,但它是。

以下是我的旧代码的样子:

 // Create the audio tag var sprite = document.createElement('audio'); var id = document.createAttribute('id'); id.nodeValue = 'audio_sprite'; var src = document.createAttribute('src'); src.nodeValue = 'my-audio-sprite.mp3'; sprite.setAttributeNode( id ); sprite.setAttributeNode( src ); // Add it to the DOM var body = document.getElementsByTagName('body')[0]; body.appendChild( sprite ); // Play/Pause to load the audio. sprite.play(); sprite.pause(); 

这是我现在正在做的。

 // Grab an existing DOM element and create an audio tag. var body = document.getElementById('hover'); body.innerHTML += '<audio id="audio_sprite"><p>Audio not supported</p></audio>'; // Apply the SRC to the audio tag. // Q: Why don't we just do that in the step above? // A: I'm not really sure why, but iOS8 doesn't like it. Sorry this is so ugly. var sprite = document.getElementById( 'audio_sprite' ); sprite.src = 'my-audio-sprite.mp3'; // Once the metadata is loaded, call play/pause so we can play the audio later. sprite.addEventListener('loadedmetadata', function() { sprite.play(); sprite.pause(); }); 

在我看来,两者都应该工作,但实际上,只有第二个为iOS8。 我希望这可以帮助别人。

我find了这个video元素,然后在脚本中创build一个源元素(不是在html中) – 奇怪,我知道:

 var video = document.getElementById('theVideo'); var source = document.createElement('source'); source.src = fileLocation source.type = "video/mp4" video.appendChild( source ); video.load(); 

我也接受这是一个老问题,但是当我在装有iOS 8.0.2的iPad上进行testing时,我发现了这个问题,并且让我出去了一天。