To recognise what video your player is playing (360 or plain), there are two ways.
1. Direct querying to YouTube API.
You can simply query by this URL:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,status&id=<YOUR_VIDEO_ID>&key=<YOUR_API_KEY>&alt=json
To obtain an API key, you must visit this page to check guide if you haven't it yet: https://developers.google.com/youtube/v3/getting-started. In the response, you should read the value contentDetails.projection
as defined there: https://developers.google.com/youtube/v3/docs/videos#contentDetails.projection.
2. Indirect guess of video format.
First way is doing additional HTTP call which may beat performance, so we can use this way also. Iframe API Player has .getSphericalProperties()
, which will be empty object if there is rectangular (plain) video presented, but will have something like {yaw: 0, pitch: 0, roll: 0, fov: 100.00004285756798}
, if you're using 360 video.