Step 1: Find the video you want to embed audio from. Take note of the video’s ‘ID’. The ID appears in the video’s URL after the ‘v=’ part and is highlighted in the screenshot below.
Step 2: Add the following snippet to your website’s HTML code and replace the ‘VIDEO_ID’ part with the video ID you copied in the previous step.
div data-video="VIDEO_ID" data-autoplay="0" data-loop="1" id="youtube-audio"> </div> <script src="https://www.youtube.com/iframe_api"></script> <script src="https://cdn.rawgit.com/labnol/files/master/yt.js"></script>
This is what it ought to look like.
The audio will not play automatically. You will have to click the play button to begin playing it. You can get it to play automatically and to loop by making a few modifications to the code. To get it to play automatically, set the value of ‘data-autoplay’ to 1. To get the audio to play on loop, set ‘data-loop’ to 1. If you plan to use this code on your own website and you expect a lot of traffic, it’s best to host the script on your own server. You can get the script from the link below.
via Digital Inspiration