Hello sir!
I am creating an audio player for my website based on plyr.js and my custom player is in a small 'div' element which has a close button. Close button calls player.destroy(), but it seems it is not good to do it.
If the close button calls player.stop() , after closing the 'div' when I hit space it starts to play again . I tried switching the value of the 'enabled' option ( player.plyr.config.enabled=false ) but I am getting an error. It says plyr is undefined. However player.plyr.config.enabled doesn't throw an error in browser console, but doesn't effect to the player too.
What should I do in order to temporarily disable or enable the plyr?
Thanks in advance!
Many other people are having issues with destroy(). We should probably try to make destroy work with their usage, rather than adding a new method. There isn't any other way to enable/disable plyr, and I don't think we need it.
Setting values in config after creating your Plyr instance isn't supported or an intended use case. It may work for some cases, but generally config isn't respected once your instance is ready.
destroy() makes the player disappear from the page, but the object is not totally gone. Documentation says it "Destroy the instance ..." so I'm thinking the object is supposed to be deleted. But, after destroy() the config is still intact and if you change the audio source value and create a new instance it keeps the old source. Strange behavior since the .source == null after the destroy().
Most helpful comment
Many other people are having issues with
destroy(). We should probably try to make destroy work with their usage, rather than adding a new method. There isn't any other way to enable/disable plyr, and I don't think we need it.Setting values in
configafter creating your Plyr instance isn't supported or an intended use case. It may work for some cases, but generally config isn't respected once your instance is ready.