Layout miniplyer window after setting the initial constraints #4291
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
, thevideoView
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 functionPlayerCore.switchToMiniPlayer
.When trying to restore the layout of the mini player,
.musicModeShowAlbumArt
is firstly tested, butminiPlayer.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 callminiPlayer.togglePlaylist()
. When it wants to show the playlist, it useswindow.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 callwindowDidEndLiveResize()
.if window.frame.height < normalWindowHeight() + AutoHidePlaylistThreshold
In here, the left hand size is
72 + DefaultPlaylistHeight = 372
.On the right hand side, the
normalWindowHeight()
is calculated based onisVideoVisible
, which is always true by default, even if the window frame is not updated withvideoWrapperView.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.