mirror of https://github.com/logseq/logseq
parent
c3df737390
commit
3dd8a849c8
|
@ -1353,7 +1353,10 @@
|
||||||
url)]
|
url)]
|
||||||
(if (and (coll? src)
|
(if (and (coll? src)
|
||||||
(= (first src) "youtube-player"))
|
(= (first src) "youtube-player"))
|
||||||
(youtube/youtube-video (last src) nil)
|
(let [t (re-find #"&t=(\d+)" url)
|
||||||
|
opts (when (seq t)
|
||||||
|
{:start (nth t 1)})]
|
||||||
|
(youtube/youtube-video (last src) opts))
|
||||||
(when src
|
(when src
|
||||||
(let [width (min (- (util/get-width) 96) 560)
|
(let [width (min (- (util/get-width) 96) 560)
|
||||||
height (int (* width (/ (if (string/includes? src "player.bilibili.com")
|
height (int (* width (/ (if (string/includes? src "player.bilibili.com")
|
||||||
|
|
|
@ -51,16 +51,20 @@
|
||||||
(<! (load-youtube-api))
|
(<! (load-youtube-api))
|
||||||
(register-player state))
|
(register-player state))
|
||||||
state)}
|
state)}
|
||||||
[state id {:keys [width height] :as _opts}]
|
[state id {:keys [width height start] :as _opts}]
|
||||||
(let [width (or width (min (- (util/get-width) 96)
|
(let [width (or width (min (- (util/get-width) 96)
|
||||||
560))
|
560))
|
||||||
height (or height (int (* width (/ 315 560))))]
|
height (or height (int (* width (/ 315 560))))
|
||||||
|
url (str "https://www.youtube.com/embed/" id "?enablejsapi=1")
|
||||||
|
url (if start
|
||||||
|
(str url "&start=" start)
|
||||||
|
url)]
|
||||||
[:iframe
|
[:iframe
|
||||||
{:id (str "youtube-player-" id)
|
{:id (str "youtube-player-" id)
|
||||||
:allow-full-screen "allowfullscreen"
|
:allow-full-screen "allowfullscreen"
|
||||||
:allow "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope"
|
:allow "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope"
|
||||||
:frame-border "0"
|
:frame-border "0"
|
||||||
:src (str "https://www.youtube.com/embed/" id "?enablejsapi=1")
|
:src url
|
||||||
:height height
|
:height height
|
||||||
:width width}]))
|
:width width}]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue