[Samsung Galaxy Nexus] armanisafarai:
I have tried almost everything to fix this problem but i just can't.

When i connect my headphone (beats and normal Samsung one) to the phone and click on play or next/previous button, nothing happens. The phone wont recognize the buttons. 4 days ago everything worked perfectly. It just suddenly happened. I was on AOKP milestone 4.

When it happened the first time, 4 days ago, i thought it might be a problem in the ROM so i wiped everything and rebooted phone. Still the same. I then re flashed the ROM several times and it was still the same. So i just got angry and put phone away. Then after 14 hours or something i plugged headphone back in the phone and opened up poweramp. Then i hit play button on headphone and suddenly it worked. I was happy, but after 1 minute i hit pause button and phone wouldn't recognize it. I kept plugging and unplugging the headphone and after several tries it worked again for a minute or two, then it didn't. This made me think it is a software problem. But when i had headphone plugged in and let music play and unplugging the headphone, the music kept playing, with no sound (Music was playing when headphone was plugged in, but then i unplugged it, but music didn't stop like it usually does when u unplug the headphone). Now the speaker didn't work. After some minutes later it magically worked again.

Now i was wondering if it is a hardware problem. Another thing to mention is that when this happens(no sound after unplugging the headphone) the phone sensor in dialer wont work. When i make a phone call to someone, the phone sensor wont work, meaning, the phone wont go black when i lift it up to my ear. Also no sound from the front speaker. So i have to use headphone to call someone, until the phone speaker works again. Then the dialer sensor will work again.

I have tried about 3 ROMS and they are all the same. I have now flashed stock Google 4.0.4 and it's still the same. Now unrooted.

Please if you don't understand some parts of my problem, ask and i will try to answer in a better way.

Will take a video soon, hopefully it will be easier to see what problem i have.

Video 1: Here I have just rebooted the phone and opened music app to see if the button on headphone works. As you can see it works the first time i plug it in. But after that it doesn't work. You can also see that once i remove the headphone, while music is playing, the phone speaker wont work. !!! Something i forgot to show you... You can see that phone speaker wont work when i unplug the headphone, but when i click up and down volume button on the phone buttons, you can hear them. Its only the music/movie/dialer etc that doesn't work.

[YOUTUBE]nn7Pf4gjo1g[/YOUTUBE]

Video 2 : Here i am testing the beats headphone, just to show you that it isn't the Samsung headphones fault.

[YOUTUBE]z63vW2Yh8fQ[/YOUTUBE]

Video 3: Here i am showing you that the phone sensor wont work in dialer.

[YOUTUBE]bnS6D73fz9k[/YOUTUBE]

Video 4: This one is very strange. I have plugged in the headphone, but when i click volume buttons on phone, you can hear it from the back speaker. This shouldn't happen right? I mean when the headphone is plugged in, then all sounds should be coming from the headphone, not the phone speaker.

[YOUTUBE]6Pm6OmKrVmE[/YOUTUBE]