🐛
This commit is contained in:
@@ -30,19 +30,24 @@ export default function YoutubeEmbeddedPlayer({
|
||||
}
|
||||
|
||||
function initPlayer() {
|
||||
if (!videoId || !containerRef.current) return
|
||||
playerRef.current = new window.YT.Player(containerRef.current, {
|
||||
videoId: videoId,
|
||||
events: {
|
||||
onStateChange: (event: any) => {
|
||||
if (event.data === window.YT.PlayerState.PLAYING) {
|
||||
mediaManager.play(playerRef.current)
|
||||
} else if (event.data === window.YT.PlayerState.PAUSED) {
|
||||
mediaManager.pause(playerRef.current)
|
||||
try {
|
||||
if (!videoId || !containerRef.current || !window.YT.Player) return
|
||||
playerRef.current = new window.YT.Player(containerRef.current, {
|
||||
videoId: videoId,
|
||||
events: {
|
||||
onStateChange: (event: any) => {
|
||||
if (event.data === window.YT.PlayerState.PLAYING) {
|
||||
mediaManager.play(playerRef.current)
|
||||
} else if (event.data === window.YT.PlayerState.PAUSED) {
|
||||
mediaManager.pause(playerRef.current)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize YouTube player:', error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -102,7 +102,7 @@ export function getParentBech32Id(event?: Event) {
|
||||
export function getRootETag(event?: Event) {
|
||||
if (!event) return undefined
|
||||
|
||||
if (event.kind === ExtendedKind.COMMENT || ExtendedKind.VOICE_COMMENT) {
|
||||
if (event.kind === ExtendedKind.COMMENT || event.kind === ExtendedKind.VOICE_COMMENT) {
|
||||
return event.tags.find(tagNameEquals('E'))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user