I use `compose-navigation` . I have a relatively h...
# compose
y
I use
compose-navigation
. I have a relatively heavy video player route which can be opened from a few other routes. Is there a way to always keep that route open in the background so it doesn't have to initialize every time? I just want to change the
videoId
used in the route every time its opened.
โž• 1
๐Ÿ‘‹ 1
This route's composable contains a video player object which takes ~5s to initialize fully and since its a video player app, its really annoying for the user to wait that time every time they want to watch another video.
i
Sounds like a good candidate to hoist that expensive object up outside of your NavHost i.e., a VideoPlayerCache object that would reuse a video player instance upon request
๐Ÿ™Œ 1
๐Ÿ‘€ 1
c
I had to do something like this and basically just made it the background of my NavHost and just always kept it around. It was for a POC app, but that ended up working pretty well. If I wanted to show the video then I would just hit the playMethod and turn the background transparent of my current screen, which would show the background video. I was basically trying to do something like what spotify had a while back.
๐Ÿ‘€ 1
๐Ÿ™Œ 1
y
Okay thank you ๐Ÿค” Ill try what I can do.