Bug 226889 - [Swift] [iOS 14.5] - Incorrect playback state reported by requestMediaPlaybackState on website first launch
Summary: [Swift] [iOS 14.5] - Incorrect playback state reported by requestMediaPlaybac...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Safari 14
Hardware: All iOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-10 11:31 PDT by Nishant Bhasin
Modified: 2021-06-17 11:32 PDT (History)
4 users (show)

See Also:


Attachments
Screen recording of simulator showing incorrect state reported by requestMediaPlaybackState (13.76 MB, video/quicktime)
2021-06-10 11:31 PDT, Nishant Bhasin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nishant Bhasin 2021-06-10 11:31:27 PDT
Created attachment 431098 [details]
Screen recording of simulator showing incorrect state reported by requestMediaPlaybackState

Hi, I work on Firefox iOS and wanted to try out the following code that allows us to request media playback state. However I always get media state as `playing` on first launch of website.

Steps to reproduce: 
- Open a media website (Ex. youtube, soundcloud) using WKWebView 
- When the website is fully loaded try to run the following code on the same website to get its media state 

Actual result:
- The code will always print playing on first launch even though nothing is playing

Expected result:
- The code should show paused or suspended as there is no media playing on those websites

```
webView.requestMediaPlaybackState({ state in
    switch state {
    case .none:
        print("TAB - none")
    case .paused:
        print("TAB - paused")
    case .playing:
        print("TAB - playing")
    case .suspended:
        print("TAB - suspended")
    @unknown default:
        fatalError()
    }
})
```

API Link: https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.h#L377
Comment 1 Radar WebKit Bug Importer 2021-06-17 11:32:30 PDT
<rdar://problem/79462265>