diff --git a/client.js b/client.js index 7c28628..e9dffb1 100644 --- a/client.js +++ b/client.js @@ -880,7 +880,22 @@ try { } function getVideoElement() { - return document.querySelector('video'); + // 1. Direct video tag in DOM + var v = document.querySelector('video'); + if (v) return v; + + // 2. Video inside iframes (e.g. embed player) + var iframes = document.querySelectorAll('iframe'); + for (var i = 0; i < iframes.length; i++) { + try { + var doc = iframes[i].contentDocument || (iframes[i].contentWindow && iframes[i].contentWindow.document); + if (doc) { + var iv = doc.querySelector('video'); + if (iv) return iv; + } + } catch (e) {} + } + return null; } function formatTime(seconds) { diff --git a/package.json b/package.json index 2502a46..5a2fecb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-yaktube-ondemand", - "version": "1.4.17", + "version": "1.4.18", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "main": "main.js", "library": "./main.js",