diff --git a/lib/device/apple_browser.js b/lib/device/apple_browser.js index 32e147577..8b81d3b93 100644 --- a/lib/device/apple_browser.js +++ b/lib/device/apple_browser.js @@ -19,23 +19,20 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice { constructor() { super(); - /** @private {!shaka.util.Lazy} */ + /** @private {!shaka.util.Lazy>} */ this.version_ = new shaka.util.Lazy(() => { // This works for iOS Safari and desktop Safari, which contain something - // like "Version/13.0" indicating the major Safari or iOS version. - let match = navigator.userAgent.match(/Version\/(\d+)/); - if (match) { - return parseInt(match[1], /* base= */ 10); + // like "Version/13.0" indicating the major.minor Safari or iOS version. + let match = navigator.userAgent.match(/Version\/(\d+)(?:\.(\d+))?/); + if (!match) { + // This works for all other browsers on iOS, which contain something + // like "OS 13_3" indicating the major & minor iOS version. + match = navigator.userAgent.match(/OS (\d+)(?:_(\d+))?/); } - - // This works for all other browsers on iOS, which contain something like - // "OS 13_3" indicating the major & minor iOS version. - match = navigator.userAgent.match(/OS (\d+)(?:_\d+)?/); if (match) { - return parseInt(match[1], /* base= */ 10); + return [parseInt(match[1], 10), parseInt(match[2] || '0', 10)]; } - - return null; + return [0, 0]; }); /** @private {!shaka.util.Lazy} */ @@ -58,7 +55,7 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice { * @override */ getVersion() { - return this.version_.value(); + return this.version_.value()[0]; } /** @@ -93,21 +90,23 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice { * @override */ requiresEncryptionInfoInAllInitSegments(keySystem, contentType) { - return contentType === 'audio'; + return !this.supportsMixedClearEncryptedContent_() && + contentType === 'audio'; } /** * @override */ insertEncryptionDataBeforeClear() { - return true; + return !this.supportsMixedClearEncryptedContent_(); } /** * @override */ requiresTfhdFix(contentType) { - return contentType === 'audio'; + return !this.supportsMixedClearEncryptedContent_() && + contentType === 'audio'; } /** @@ -133,6 +132,19 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice { return false; } + /** + * Apple has fixed the mixed clear/encrypted content issue in Safari 26.4 + * @return {boolean} + * @private + */ + supportsMixedClearEncryptedContent_() { + const version = this.version_.value(); + if (version[0] >= 27) { + return true; + } + return version[0] === 26 && version[1] >= 4; + } + /** * @return {boolean} * @private