Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does the player reset when only the dimensions have changed? #247

Closed
dancancro opened this issue Jun 20, 2020 · 15 comments · Fixed by #278
Closed

Why does the player reset when only the dimensions have changed? #247

dancancro opened this issue Jun 20, 2020 · 15 comments · Fixed by #278

Comments

@dancancro
Copy link
Contributor

If I pass in opts.width and opts.height, and they change while the player is playing, the player completely resets. I modified the code to keep this from happening and it works fine. Was there some rationale behind having it work this way?

@ruisaraiva19
Copy link
Collaborator

@dancancro I don't think there is a rationale behind having opts.width and opts.height triggering a player reset. @tjallingt please let us know if you disagree.

@dancancro Can you open a PR with this small change 🙏 ?

@tjallingt
Copy link
Owner

If we can avoid resetting we definitely should, probably never encountered this issue because I usually set width and height to 100%

@dancancro
Copy link
Contributor Author

I can do a pull request but I'm stuck. My editor, VSCode, is removing spaces after "if"s and "switch"es. How do I get my editor, VSCode, to not automatically apply eslint fixes on save? This code in .vscode/settings.json isn't doing it...

{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": false
  }
}

@ruisaraiva19
Copy link
Collaborator

@dancancro you can save changes without formating your code by running the VSCode command called File: Save without Formatting.

@dancancro
Copy link
Contributor Author

I don't know how to run a VSCode command. I see menus and menu items that I can click. I don't see a menu item for saving without formatting.

@ruisaraiva19
Copy link
Collaborator

You can run "Command + Shift + P" to open the Command Palette and type "save without" until you see "File: Save without Formatting" command and use that.

@dancancro
Copy link
Contributor Author

How do I fix this pull request? It's complaining about the format of the commit message of a previous commit.

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 7.13.1-canary.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 7.13.2-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dancancro
Copy link
Contributor Author

I installed the new version and it still has this problem. When the player is resized while playing, it stops playing.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2022

🎉 This issue has been resolved in version 7.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dancancro
Copy link
Contributor Author

@tjallingt I tried it again. It's not fixed. The player restarts when you resize the window.

@dancancro
Copy link
Contributor Author

@tjallingt I somehow earlier missed the workaround you posted for setting height and width to 100% and then presumably having the containing element control the dimensions. That's reasonable, but there is an intervening div whose dimensions can't be set. This means that the iframe will fill the specified width but not the specified height. I tried setting height and width of the Youtube component's style, but the Youtube component only accepts a className, not a style. Is that a shortcoming that can be corrected?

Since you mentioned that by setting the height and width to 100% you hadn't encountered this problem, I suspect that you did something else to handle dynamically changing dimensions. If so, what was that?

@dancancro
Copy link
Contributor Author

dancancro commented Jan 19, 2024

@tjallingt okay, this is very odd. I tried setting the Youtube component's className to "youtube-player" and defining

.youtube-player {
  height: inherit;
}

and instead of putting this class on the containing div, it rendered simply <div class>, and put the "youtube-class" on the iframe` instead, thus nullifying this height inheritance. It's almost as if this was done on purpose to prevent the control of the player's height this way. So strange.

@dancancro
Copy link
Contributor Author

@tjallingt okay, this is weird but works. I added the class to the outer div too.

 <div className="youtube-player" style={{ height: thumbnailed ? thumbHeight : height, width: thumbnailed ? thumbWidth : width }}>
  <YouTube videoId={videoId} 
          className="youtube-player" 
          opts={{
             height: '100%',
             width: '100%',
             playerVars: {
                autoplay: autoplay ? 1 : 0,
                start: start === null ? null : +start,
                end: end === null ? null : +end
          }
         }} 
        onReady={onPlayerReady(video)}
        onStateChange={onPlayerStateChange(video)} />
</div>
<style>
.youtube-player, .youtube-player > div {
  height: inherit;
}
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants