Closed leopku closed 1 year ago
Just one line of css is all it takes.
#oplayer {
aspect-ratio: 16/9; // Any ratio you want
}
Sorry, I didn't describe my problem clearly.
I'm using react component @oplayer/react
.
After the react player component rendered, the player won't change it's size while container changed. There wasn't problem about aspect ratio.
Any advice?
The player will fill the container. You just need to set the width and height of the container, and the size of the player will change with the container.
Maybe I don't know what you want. You can use pictures to describe the current situation and expectations.
ps: 如果你会中文,可以用中文描述。
1、播放器有办法自适应 container 大小没?
截图是在一个弹出的新窗口中,留意截图下面的空白部分。
2、手动调整弹出窗口的大小,播放器大小不会自动调整。有没有类似 changeSize(width, heigh) 这样方法,在窗口的大小变更回调中可以调用。
PS:oplayer 这样的插件式设计个人非常喜欢,目前在试验从 nplayer 切到 oplayer
传递 aspect-ratio 为 0 试试
不行,设了 aspectRatio={0} 后白屏了,控制台没有报错。
<ReactPlayer
plugins={plugins}
aspectRatio={0}
ref={player}
autoplay={true}
source={source}
/>
😂 你把 react 复制出来,去掉aspectRatio那部分,只留ref那层就好了, 或者等晚点我改一下,再或者 css 覆盖下, container》div height100 width100
试了一下,还是不行。等你改吧。谢了先。
v 1.2.5 released.
<ReactPlayer
plugins={plugins}
aspectRatio={0}
ref={player}
autoplay={true}
source={source}
/>
Perfect. It fixed. Thanks a lot.
@shiyiya 全新项目,aspectRatio
不起作用了?
奇怪了,我这新窗口弹出后,没有随 container 改变大小
奇怪了,我这新窗口弹出后,没有随 container 改变大小
被其他样式影响了吧
奇怪了,我这新窗口弹出后,没有随 container 改变大小
被其他样式影响了吧
应该不是。两处代码一样。
我再查查
🚀 Feature Proposal
Change player width & height when/after container size changed
Motivation
When container size changed smaller, player size keep no change.
Example
Please provide an example for how this feature would be used.
Pitch
Why does this feature belong in the oplayer ecosystem?