sampotts / plyr

A simple HTML5, YouTube and Vimeo player
https://plyr.io
MIT License
26.59k stars 2.93k forks source link

Hide controls at the beginning and show them after the video started. #1297

Open TheZoker opened 5 years ago

TheZoker commented 5 years ago

I want the player to only show the ['play-large'] when the video is not played and then ['play-large', 'play', 'volume', 'fullscreen', 'progress'] if the video is playing. So just like youtube does it (big play button in the middle and if the user clicks on that and the video plays, then the other controls are shown). How can I archive that?

I could not find any setters for the controls.

So something like:

const player = new Plyr('#player', {
    controls: ['play-large'],
});
player.on('play', event => {
    player.controls = ['play-large', 'play', 'volume', 'fullscreen', 'progress'];
});
sp4r74cus commented 5 years ago

joining to this request. its very annoying to see the controls show on player load, then hide and show again when video starts to play.

benjibee commented 5 years ago

This is (at least partially) address by #1115, the resolution being adding a class connected to .plyr.plyr--stopped such as:

.plyr.plyr--stopped .plyr__controls { display: none }

This would hide everything but the play button, for example. Using this method you could hide anything you wish. Though I agree that this should be a config option.

hirbod commented 4 years ago

Thanks for that, I also like the CSS approach

nitaaikumar commented 4 years ago

This is (at least partially) address by #1115, the resolution being adding a class connected to .plyr.plyr--stopped such as:

.plyr.plyr--stopped .plyr__controls { display: none }

This would hide everything but the play button, for example. Using this method you could hide anything you wish. Though I agree that this should be a config option.

Actually the above code hides the audio player completely. Had a hard time to figure out why the audio player was not appearing due to this. So this one would be better:

.plyr--video.plyr--stopped .plyr__controls { display: none; }

Dipesh-Das97 commented 2 years ago

I want to do something exactly opposite. Don't want the button to show when the video is paused, but only the beginning video. Any ideas on this?

michaelpumo commented 8 months ago

I think it's actually better to set the opacity rather than display none because it will keep the controls interactive.

If you set display none...then seeking through the progress bar pauses the player because the click lands on the video itself and pauses it, which is probably not what you want to happen.

.plyr--video.plyr--stopped .plyr__controls,
.plyr--video.plyr--paused .plyr__controls {
  opacity: 0;
}