The first device for playing music was the gramophone, also called the phonograph. The first recorded patent for one was made in 1857 however this could only record sound to a visible medium and had no way of playing it back.
The first example of recording and replaying sound was on November 29th 1877 by Thomas Edison.