youtube player with { playerVars: { start }, don't start on that time #1825
Replies: 4 comments
-
I am experiencing similar issues |
Beta Was this translation helpful? Give feedback.
-
I am also facing this |
Beta Was this translation helpful? Give feedback.
-
i fixed this by using youtube-nocookie.com instead of youtube.com in my URL, it seems like the youtube user cookies interfere with things |
Beta Was this translation helpful? Give feedback.
-
Thank you. Until you taught me this, this is how I was getting around it. const handleClick = (videoId: string, start: number) => {
if (currentVideoId == videoId) {
setStart(start);
} else {
setCurrentVideoId(videoId)
setTimeout(() => setStart(start), 1600)
}
}; P.S |
Beta Was this translation helpful? Give feedback.
-
Current Behavior
In youtube player, I specified a playback start time with {playerVars: start}. It would be at that time for a moment, but was immediately overwritten by another time.
That time was probably the continuation of the most recently viewed video.
I uploaded this Current Behavior to youtube because my English is not good.
However, if I delete the youtube Cookie or never watched the video in the first place, this problem does not occur.
Also, I've tried triggering useState with onReady or onStart, but it doesn't work.
(Wouldn't the ideal behavior be to, for example, not load the youtube cache when youtube plays?)
japanese(my origin text)
youtube playerにおいてplayerVars startで再生開始時間を使用した場合、一瞬だけその時間になるが、すぐに別の時間に上書きされる。
おそらく、直近にその動画を見ていた続きの時間だ。
僕は英語が下手だから、この現象をyoutubeにアップロードした。
ただし、youtube Cookieを削除したり、そもそも見たこと無い動画であれば、この問題は発生しない。
また、onReadyやonStartでuseStateを起爆してみたけど、ダメだったよ。
(理想的な振る舞いとして、例えば、youtube再生時にyoutubeのキャッシュを読み込まないようなことはできないだろうか?)
Expected Behavior
Playback from the time specified by you, without being overwritten.
japanese(my origin text)
上書きされずに、自分が指定した時間から再生してほしい。
Steps to Reproduce
my xperimental code
import React, { useContext, useEffect, useState, createContext } from "react"
import Link from "next/link"
import ReactPlayer from 'react-player/youtube';
export default function Home() {
const [start, setStart] = useState(120);
const [url, setUrl] = useState("https://youtu.be/2T4kKYAJrAM?t=886");
}
type Player = {
url: string,
start: number,
}
const Player = ({ url, start }: Player) => {
const [hasWindow, setHasWindow] = useState(false);
useEffect(() => {
if (typeof window !== "undefined") {
setHasWindow(true);
}
}, []);
};
Environment
"next": "14.0.2",
"react": "^18",
"react-dom": "^18",
"react-player": "^2.14.1",
"react-youtube": "^10.1.0"
Supplement
The same phenomenon was seen on react-youtube on another oss (my code).
When we tried seekTo on react-youtube, we were able to manipulate the playback time of the currently playing video. However, it was not possible to manipulate video transition and playback time at the same time.
I haven't tried seekTo in youtube-olayer yet.cuz, i could not understand how to do in react-player...
I'm a non-native English speaker.
If you notice my any mistakes, I'd be happy to have them pointed out.
japanese(my origin text)
同じ現象が別のoss react-youtubeでも確認された。
react-playerではseekToは試していないが、react-youtubeでは結果は対して変わらなかったよ。
自分の知識ではreact-pkayerでseekToを使う方法が分からなかったから試していないけど…
僕は非英語ネイティブだよ。
もし間違いに気がついたら指摘してもらえると嬉しい。
Beta Was this translation helpful? Give feedback.
All reactions