fix off center button

This commit is contained in:
Anthony 2021-08-30 21:18:12 +02:00
parent 1a4bc2a543
commit 391e2e25a2
No known key found for this signature in database
GPG key ID: C386D3C93D50E356

View file

@ -564,12 +564,28 @@ export default React.memo<Props>(function VideoJs(props: Props) {
player.on('volumechange', onVolumeChange); player.on('volumechange', onVolumeChange);
player.on('error', onError); player.on('error', onError);
player.on('ended', onEnded); player.on('ended', onEnded);
player.on('loadstart', function(){
console.log('LOADED HERE');
const playBT = document.getElementsByClassName('vjs-big-play-button')[0];
const videoDiv = player.children_[0];
const controlBar = document.getElementsByClassName('vjs-control-bar')[0];
const leftWidth = ((videoDiv.offsetWidth - playBT.offsetWidth) / 2) + 'px';
const availableHeight = videoDiv.offsetHeight - controlBar.offsetHeight;
const topHeight = (((availableHeight - playBT.offsetHeight) / 2) + 11) + 'px';
playBT.style.top = topHeight;
playBT.style.left = leftWidth;
playBT.style.margin = 0;
})
// on ios, show a play button when paused // on ios, show a play button when paused
if (IS_IOS) { if (IS_IOS) {
const playBT = document.getElementsByClassName('vjs-big-play-button')[0]; const playBT = document.getElementsByClassName('vjs-big-play-button')[0];
player.on('pause', function() { player.on('pause', function() {
const videoDiv = player.children_[0]; const videoDiv = player.children_[0];
const controlBar = document.getElementsByClassName('vjs-control-bar')[0]; const controlBar = document.getElementsByClassName('vjs-control-bar')[0];
const leftWidth = ((videoDiv.offsetWidth - playBT.offsetWidth) / 2) + 'px'; const leftWidth = ((videoDiv.offsetWidth - playBT.offsetWidth) / 2) + 'px';