Why isn't my phone registering my earphones?

So about a month ago my phone just wouldn’t recognise my earphones even though they were plugged in. To test that that it wasn’t that my plug was full of dust I put my charger in and it worked. Also rarely (I mean rarely) it connects but then it disconnects almost immediately.

crwdns2934089:0crwdne2934089:0 crwdns2934093:0crwdne2934093:0

crwdns2934109:0crwdne2934109:0

crwdns2889612:0crwdne2889612:0 0
crwdns2934285:0crwdne2934285:0