mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-04-24 07:08:08 -05:00
Battle-log: Support seeking to a timestamp in <youtube> tags
This commit is contained in:
parent
17eef20bcf
commit
2cca9bc1bd
|
|
@ -929,6 +929,7 @@ export class BattleLog {
|
|||
this.players.push(null);
|
||||
const idx = this.players.length;
|
||||
this.initYoutubePlayer(idx);
|
||||
console.log(src, time);
|
||||
return {
|
||||
tagName: 'iframe',
|
||||
attribs: [
|
||||
|
|
@ -936,6 +937,7 @@ export class BattleLog {
|
|||
'width', width, 'height', height,
|
||||
'src', `https://www.youtube.com/embed/${videoId}?enablejsapi=1&playsinline=1${time ? `&start=${time}` : ''}`,
|
||||
'frameborder', '0', 'allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture', 'allowfullscreen', 'allowfullscreen',
|
||||
'time', (time || 0) + "",
|
||||
],
|
||||
};
|
||||
} else if (tagName === 'formatselect') {
|
||||
|
|
@ -1069,7 +1071,8 @@ export class BattleLog {
|
|||
static initYoutubePlayer(idx: number) {
|
||||
const id = `youtube-iframe-${idx}`;
|
||||
const loadPlayer = () => {
|
||||
if (!$(`#${id}`).length) return;
|
||||
const el = $(`#${id}`);
|
||||
if (!el.length) return;
|
||||
const player = new window.YT.Player(id, {
|
||||
events: {
|
||||
onStateChange: (event: any) => {
|
||||
|
|
@ -1082,7 +1085,12 @@ export class BattleLog {
|
|||
},
|
||||
},
|
||||
});
|
||||
const time = Number(el.attr('time'));
|
||||
if (time) {
|
||||
player.seekTo(time);
|
||||
}
|
||||
this.players[idx - 1] = player;
|
||||
|
||||
};
|
||||
// wait for html element to be in DOM
|
||||
this.ensureYoutube().then(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user