I have used AVPlayer
to play video on my swift application. I want to place a Play button (custom button) at the middle of video. I know how to play and pause video on tapping the button.
I couldn't find how to show/hide the custom button when the video is played/paused from default buttons? Are there any listener or something which triggers when the video is played/paused?
I also want to hide the "Audio & Subtitles" icon from default control.
Here is how you can listen to player state changes and hide/show buttons: (assume your player is named
player
, and button isplayButton
)If rate of player is equal to 0 it means that video is not playing.