The new feature, which must be activated by the user and is off by default, would create a status update on Facebook that identifies the song a user is listening to and provide a 30-second preview of it that's available to the user's friends.
Facebook, which announced the move in a post on its official blog on Wednesday, is working with streaming music services Spotify, Rdio and Deezer to offer the music previews.
If a television show is detected, Facebook would highlight the specific season and episode that the user is watching and share it in their news feed.
The new tool comes as Facebook is increasingly competing with Twitter Inc to become the main online venue where consumers discuss television shows, sports and other entertainment in real time.
The new feature activates the microphone on a smartphone and detects the music, movie or television show playing in the background, similar to the way the popular Shazam app works.
Once users activate the feature, the technology attempts to recognize the music or video playing in the background any time a Facebook user composes a status update.
Facebook said only songs or videos would be identified and the feature, which recognizes "millions" of songs, wouldn't store sounds in the background.
The new feature will be available on the Android and iOS versions of its app in the U.S. in the coming weeks, the company said.