mediaPlaybackRequiresUserAction deprecated and iOS 9
Asked Answered
A

1

6

WKWebViewConfiguration:

WKWebViewConfiguration:

  • According to Apple's documentation mediaTypesRequiringUserActionForPlayback is only for iOS 10+.

    In WKWebViewConfiguration:

    @available(iOS 10.0, *)
    open var mediaTypesRequiringUserActionForPlayback: WKAudiovisualMediaTypes
    

So here is my question:

as mediaPlaybackRequiresUserAction is deprecated for iOS 9, and mediaTypesRequiringUserActionForPlayback is only for iOS 10+, what can I use for iOS 9?

Alpers answered 26/9, 2017 at 10:13 Comment(0)
N
5

There is a property on the WKWebViewConfiguration object you initialize your WKWebView with named requiresUserActionForMediaPlayback.

Nevanevada answered 27/9, 2017 at 5:29 Comment(2)
It was so obvious that I missed it... Thank you, you deserved your points! ;)Alpers
Yeah, my code (Objective-C) looks something like this now: if ( @available(iOS 10.0, *) ) { configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone; } else { if ( @available(iOS 9.0, *) ) { configuration.requiresUserActionForMediaPlayback = NO; } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" configuration.mediaPlaybackRequiresUserAction = NO; #pragma clang diagnostic pop } }Nevanevada

© 2022 - 2024 — McMap. All rights reserved.