First and Foremost in order to play a song by ear, you must be able to find out what key the song is in... A trick I did, LEARN YOUR SCALES....... It will make the process easier, for example if you learn yourself scales and you sit and listen to a song. I usually find that one note that is basically in harmony with the song, find out what scale fits that song.. Thats something i did until i got used to it, its a growing process. You start off slow and it a eventually pick up. Knowing your scales will help broaden the search for the notes and changes, then you will have like 8 notes to play with to see what is next, in a basic like way now, keep in mind there are chords like 7th's that will include notes outside the scale or half stepping, im just giving you basics to work with....If im wrong anyone tell me.....lol, thats what I do from the guitar and I play keys a little