Plyr: Disabling the Plyr without destroying

Created on 7 Jun 2018  路  2Comments  路  Source: sampotts/plyr


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!

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 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.

All 2 comments

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().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Generalomosco picture Generalomosco  路  3Comments

michaelmano picture michaelmano  路  3Comments

Antonio-Laguna picture Antonio-Laguna  路  3Comments

Zsavajji picture Zsavajji  路  3Comments

Lycanthrope picture Lycanthrope  路  4Comments