Skip to content

Layout miniplyer window after setting the initial constraints #4291

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

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

uiryuu
Copy link
Member

@uiryuu uiryuu commented Mar 24, 2023

Otherwise window.frame.height will always be 72, which is the height without the video view. This incorrect height will affect later calucations.


Analysis

When I was tracking down the issue #4088, I found that in PlayerCore.switchToMiniPlayer, the videoView is removed from the main window and added into the mini player. However, even through constraints are set correctly, the window frame is not updated immediately, and the window height will be 72 throughout the function PlayerCore.switchToMiniPlayer.

When trying to restore the layout of the mini player, .musicModeShowAlbumArt is firstly tested, but miniPlayer.toggleVideoView() is not called, in which we manually set the window frame. This is because the default behavior is album art being shown (var isVideoVisible = true). So the window frame height is still 72.

After that, if .musicModeShowPlaylist is true, we will call miniPlayer.togglePlaylist(). When it wants to show the playlist, it uses window.frame to get the current window size (in our case it is still 72) and then calculate the new height, which is the height with the playlist. After setting the frame with the calculated new height and done the window resizing animation, the system will call windowDidEndLiveResize().

if window.frame.height < normalWindowHeight() + AutoHidePlaylistThreshold

In here, the left hand size is 72 + DefaultPlaylistHeight = 372.

private func normalWindowHeight() -> CGFloat {
  return 72 + (isVideoVisible ? videoWrapperView.frame.height : 0)
}

On the right hand side, the normalWindowHeight() is calculated based on isVideoVisible, which is always true by default, even if the window frame is not updated with videoWrapperView.frame.height, normalWindowHeight() incorrectly includes the height of the video. This will cause our window height not exceeding the threshold and make it automatically collapse the playlist.

Solution

After setting up the constraints for video in the mini player, I manually layout the mini player, so that the window frame got updated immediately (should be 72 + height of the video), so that in windowDidEndLiveResize() the window height is correct, which will pass the threshold thus will not trigger a collapse.

I'm not sure whether this will fix #4088 but it at least fix some part of that issue.

Otherwise `window.frame.height` will always be 72, which is the height
without the video view. This incorrect height will affect later
calucations.
@uiryuu uiryuu requested a review from low-batt March 24, 2023 09:36
@low-batt
Copy link
Contributor

Sorry I'm slow to get to this. I should be able to take a look at this tomorrow.

Copy link
Contributor

@low-batt low-batt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled PR, built and tested under Ventura and Catalina.
Looks good to me, however there are still problems with entering and leaving the mini player. This may be due to some of the outstanding critical PRs that need to be merged. Need to get those reviewed and merged into develop and then check IINA's behavior.

@uiryuu uiryuu merged commit edf9ae8 into develop Mar 27, 2023
@uiryuu uiryuu deleted the layout-after-constraints branch March 27, 2023 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Playlist/Chapters no longer shows automatically in Music mode
2 participants