HTML5 视频播放不适用于 Safari(Mac 和 iOS)
HTML5 Video playback not working with Safari (Mac and iOS)
我的一个网站上有一些视频。视频使用 HTML5 视频标签,并在呈现标签时使用了最佳实践。它在 Chrome、Firefox、Edge 甚至 Internet Explorer 中运行良好。除了 Safari!即使是 Facebook 检测视频和分享也很完美。
在 Safari 中,它检测到视频,加载浏览器控件,但无法播放。我不认为这是视频标签的问题,因为当我在新标签页中打开视频时,它也不起作用。我尝试使用 miro video converter
和 Apple 设置重新编码视频,但没有任何改变。我可以下载视频并使用 Mac Preview
播放,没有任何问题。
作为附加信息,我在 IIS 7 上使用 ASP.net。
我在控制台中看到这个错误:Failed to load resource: Plug-in handled load
这是其中一页:https://www.parscanada.com/_104189
这是 Mac 的 Safari 页面的屏幕截图:
下面是 iOS 的 Safari 页面的屏幕截图(模拟器 - 与设备相同):
问题已解决,使用 http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx (link is dead, but you can find it in archive.org)
中 Scott Mitchel 的代码
将正确的 headers 发送回 Safari 请求似乎有问题。我用我的原始代码替换了 Scott 的部分代码,一切似乎都运行良好。
这是 scot 的代码摘要:
/// <summary>
/// An abstract HTTP Handler that provides resumable file downloads in ASP.NET.
///
/// Created by:
/// Scott Mitchell
/// mitchell@4guysfromrolla.com
/// http://www.4guysfromrolla.com/ScottMitchell.shtml
/// </summary>
/// <remarks>
/// This class is a fairly close port of Alexander Schaaf's ZIPHandler HTTP Handler, which I found online at:
///
/// Tracking and Resuming Large File Downloads in ASP.NET
/// http://www.devx.com/dotnet/Article/22533/1954
///
/// I also found a similar version of this code in the download for the September 2006 issue of MSDN Magazine:
/// http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/MSDNMag2006_09.exe
///
/// Alexander's code is in Visual Basic and was written for ASP.NET version 1.x. I ported the code to C#,
/// refactored portions of the code, and made use of functionality and features introduced in .NET 2.0 and 3.5.
/// </remarks>
我的一个网站上有一些视频。视频使用 HTML5 视频标签,并在呈现标签时使用了最佳实践。它在 Chrome、Firefox、Edge 甚至 Internet Explorer 中运行良好。除了 Safari!即使是 Facebook 检测视频和分享也很完美。
在 Safari 中,它检测到视频,加载浏览器控件,但无法播放。我不认为这是视频标签的问题,因为当我在新标签页中打开视频时,它也不起作用。我尝试使用 miro video converter
和 Apple 设置重新编码视频,但没有任何改变。我可以下载视频并使用 Mac Preview
播放,没有任何问题。
作为附加信息,我在 IIS 7 上使用 ASP.net。
我在控制台中看到这个错误:Failed to load resource: Plug-in handled load
这是其中一页:https://www.parscanada.com/_104189
这是 Mac 的 Safari 页面的屏幕截图:
下面是 iOS 的 Safari 页面的屏幕截图(模拟器 - 与设备相同):
问题已解决,使用 http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx (link is dead, but you can find it in archive.org)
中 Scott Mitchel 的代码将正确的 headers 发送回 Safari 请求似乎有问题。我用我的原始代码替换了 Scott 的部分代码,一切似乎都运行良好。
这是 scot 的代码摘要:
/// <summary>
/// An abstract HTTP Handler that provides resumable file downloads in ASP.NET.
///
/// Created by:
/// Scott Mitchell
/// mitchell@4guysfromrolla.com
/// http://www.4guysfromrolla.com/ScottMitchell.shtml
/// </summary>
/// <remarks>
/// This class is a fairly close port of Alexander Schaaf's ZIPHandler HTTP Handler, which I found online at:
///
/// Tracking and Resuming Large File Downloads in ASP.NET
/// http://www.devx.com/dotnet/Article/22533/1954
///
/// I also found a similar version of this code in the download for the September 2006 issue of MSDN Magazine:
/// http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/MSDNMag2006_09.exe
///
/// Alexander's code is in Visual Basic and was written for ASP.NET version 1.x. I ported the code to C#,
/// refactored portions of the code, and made use of functionality and features introduced in .NET 2.0 and 3.5.
/// </remarks>