solid-software / flutter_vlc_player

📺 Flutter VLC powered video player.
514 stars 248 forks source link

PSA for people using the player on a widget that automatically matches the size of the screen instead of fullscreen #270

Open arianneorpilla opened 2 years ago

arianneorpilla commented 2 years ago

There are use cases for not using a built-in full screen mode and instead making the player match the size of the screen -- you can have widgets overlay on top of the player if you need to.

The problem is, the screen blacks out when you rotate and change the orientation. Another problem is that changing the orientation causes your entire screen, and the player to rebuild, which for some reason makes the player resume when paused.

The solution for this is to prevent orientation changes and tracking the orientation before all instances where a pause is executed. If users were in portrait before the pause, they'll remain locked to portrait until the orientation is unlocked until the play function is called.

This means a user will never have an unexpected resume, because they can never rotate when paused anyway.

To solve the problem where the screen blacks out when you auto-rotate the screen, you can track the orientation and update it with every build. If the orientation is different from what was from last rebuild, you can set a future delayed function to wait 50ms, then tell the player to seek back to the 50ms, where they originally were during the build.

You have to make this delayed, as the build has to finish and experience the problem. Your seek bandaid happens just a bit after the build, and it will get rid of the corruption near instantly.

This will fix the black/green jitter corruption issue that you get when auto rotating and having the player fit the maximum width of the screen.

I don't know if anyone has documented this problem yet, but I'm happy to share it if anyone is stumped doing the same thing, I know I was.

Micae1o commented 2 years ago

Can you share your code please? I faced this problem and don't know how to solve it in code