How do you embed the audio portion of any YouTube video into your website? An easy option would be that you convert the YouTube video into an MP3 file and upload it to an audio hosting site like Soundcloud. This will work but YouTube is very likely to have a problem with your approach due to copyright issues
There’s a simpler approach as well that uses the official YouTube API and requires no file conversion.
You can embed any YouTube video in your web pages and visitors on your site will be able to play and pause the
video audio with a simple click. With this technique, you can also use a YouTube video as background audio that runs in a loop.
HOW TO EMBED YOUTUBE AUDIO
It takes just one step to embed a YouTube audio. Open any YouTube video and make a note of the YouTube Video ID you can get it from any youtube video URL (a string of 11 characters).
Next copy-paste the code below anywhere on your website and replace VIDEO_ID with actual ID of your YouTube video.
There are just few line of codes that you have to change it before using them in to your website. For instance, if you set data-autoplayto 1, the audio will begin playing immediately on page load. Likewise, set data-loop to 1 and the audio will play continuously in a never-ending loop until manually stopped.
YOUTUBE AUDIO – THE TECHNICAL DETAILS
Don’t you think its easy way to embed any song from youtube in to your website so that people can listen is easily.