amplitudejs
amplitudejs copied to clipboard
Youtube Support
Why should this feature be implemented?
It makes it easier to embed music into a website.
Feature Description
I would like to request that Amplitude can play music directly from a Youtube URL:
Amplitude.init({
"songs": [
{
"name": "Risin' High (feat Raashan Ahmad)",
"artist": "Ancient Astronauts",
"album": "We Are to Answer",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"cover_art_url": "../album-art/we-are-to-answer.jpg"
},
]
});
In it's most basic version, it would stream the audio from Youtube instead of from the MP3 file.
On a more complete version, it could also extract metadata from the Youtube video directly:
Amplitude.init({
"songs": [
// MP3, backwards compatible
{
"name": "Risin' High (feat Raashan Ahmad)",
"artist": "Ancient Astronauts",
"album": "We Are to Answer",
"url": "foo.mp3",
"cover_art_url": "../album-art/we-are-to-answer.jpg",
},
// Just feed the audio from Youtube instead of MP3
{
"name": "Risin' High (feat Raashan Ahmad)",
"artist": "Ancient Astronauts",
"album": "We Are to Answer",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"cover_art_url": "../album-art/we-are-to-answer.jpg",
"source": "youtube" // or automatically inferred by parsing the URL string above
}
},
// Just Youtube URL
{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"source": "youtube", // or automatically inferred by parsing the URL string above
// Name and Cover art URL ommited, fallback to extracing it from Youtube.
// https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api
// Example for the video above: https://img.youtube.com/vi/XfR9iY5y94s/0.jpg
},
}
]
});
A new configuration item could be added to give granular control over YT behavior:
Amplitude.init({
"youtube_config": {
"cover_art_fallback_behavior": "youtube", // extract thumbnail from youtube video
"cover_art_fallback_behavior": "default" // use value from "default_album_art"
}
});