Invidious is an alternative front-end to YouTube
Handle equirectangular projections for VR (#2379)
syeopite50c8afb52542
diff --git a/assets/js/player.js b/assets/js/player.jsindex 0de18d92..a8a75f6e 100644--- a/assets/js/player.js+++ b/assets/js/player.js@@ -151,7 +151,12 @@ player.on('error', function (event) {// Enable VR video supportif (video_data.vr && video_data.params.vr_mode) {player.crossOrigin("anonymous")- player.vr({projection: "EAC"});+ switch (video_data.projection_type) {+ case "EQUIRECTANGULAR":+ player.vr({projection: "equirectangular"});+ default: // Should only be "MESH" but we'll use this as a fallback.+ player.vr({projection: "EAC"});+ }}// Add markersdiff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex 27d85b92..d9c07142 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -762,7 +762,12 @@ struct Videoenddef is_vr : Bool?- info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_s == "MESH"+ projection_type = info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_s+ return {"EQUIRECTANGULAR", "MESH"}.includes? projection_type+ end++ def projection_type : String?+ return info.dig?("streamingData", "adaptiveFormats", 0, "projectionType").try &.as_senddef wilson_score : Float64diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecrindex aeb0f476..68e7eb80 100644--- a/src/invidious/views/watch.ecr+++ b/src/invidious/views/watch.ecr@@ -63,7 +63,8 @@ we're going to need to do it here in order to allow for translations."params" => params,"preferences" => preferences,"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,- "vr" => video.is_vr+ "vr" => video.is_vr,+ "projection_type" => video.projection_type}.to_pretty_json%></script>