Is it possible to insert the AUDIO of a youtube video into a website? (I will give credit due credit)

I’m trying to insert audio (Liebestraum No. 3 by Liszt) into a website in the form of buttons that when clicked on by a user, will play the certain audio that I insert into the code. But because of youtube and its rabbit hole of copyright rules, I’m not sure if this is possible. I just need to know if you can actually do this(legally).

1 Like

You can download the audio file and use the audio tag.

<button onclick="playAudio()">Click me to play Liebestraum</button>
<audio id="myAudio" src="the path which your file is.mp3"></audio>

<script>
function playAudio() {
  var audio = document.getElementById("myAudio");
  audio.play();
}
</script>

Or you can use the API and stream the audio.

5 Likes

Official points from Youtube ToS:

  • You are not allowed to download or copy any videos from YouTube without explicit consent from the copyright holder.

  • You are not allowed to access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as expressly authorized by the Service; or (b) with prior written permission from YouTube and, if applicable, the respective rights holders.

A. (I got the basic ToS by asking a AI to read the page and tell me a summary, then I just wrote the important parts, credit to Copilot by Microsoft)
B. Oh yeah, I also re-read the actual ToS to check, it took a hour.

To sum it up, it’s fine if:

  1. You have permission from Liszt in this case.
  2. You embed the audio from Youtube.
  3. I believe if you have Youtube premium you can download and embed it as a file, but I’m not completely sure here. (ToS is kind of vague)

(so no installing the actual audio, then embedding if number 2)
I will mention the fact that it doesn’t really matter in the end, as there’s no real way to verify whether an embedded file is actually from YouTube or not. I’m not going to recommend it though, because it breaks the ToS.

You can also check the description of the video in case number 1. Most of the time there’s some sort of info about usage (for music and such). If it’s within those terms, then you can use a download without any issues. You can also find the song on a site like soundcloud, then download and embed it from there without any issues (not mentioned at all in ToS, besides crediting the creator).

Since I’m not really good with html or javascript, I’d follow @WindLother’s example, and check Youtube’s documentation if you want to stream the audio (for embedding the player with the video Youtube supplies the html code, which you can access via the share button, then just click embed)

Hope this helped!

Not sure about copyright rules, but a python backend using pytube would work (maybe one route to download the music and another route to send music files to an audio tag).

Thank for the info, but btw, Liszt has been dead for over 100 years…

One way you could do it is embed the video on your website but hide it with css. Than use YouTube’s iframe api to control it with buttons that you create. I’ve done this many times before for audio from Instagram

You can read about the YouTube embed api here: YouTube Player API Reference for iframe Embeds  |  YouTube IFrame Player API  |  Google for Developers

I mean whoever actually put the song onto youtube (so the channel)