There is no real mystery or even difficulty to "playing by ear" in my experience. For me it is hearing a tune over and over until it is in my head, and then "figuring it out" on the saxophone without having to refer to a written page of music. The figuring it out doesn't need to be fast or spontaneous. Often it is done by bits and pieces a little bit at a time.
I grew up in a small town where the closest music store was 200 miles away, and of course there was no internet. If I wanted to play a tune, I couldn't just go out and buy the music. After I had learned most of the notes and keys on my saxophone when I heard a song like "Take Five" on the radio, I bought the record and learned to play the melody a few notes at a time by hearing it over and over again. Eventually, I could play right along with Paul Desmond picking up his tone and style as I went along. I did the same with Stan Getz's Desifinato, Plas Johnson's The Pink Panther, and Boots Randolph's Yakkety Sax. The more I did it, the easier it got.
After a while I began to think in terms of musical intervals which opened the door to playing tunes in different keys than the one I learned them in. My advice to anyone wanting to learn to play by ear is to start with Twinkle Twinkle Little Star and go on from there.