async function fetchPodcastFeed(url) {
const response = await fetch(`https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(url)}`);
const data = await response.json();
return data.items;
}
async function createPodcastPlayer() {
const podcastUrl = "https://cloud.mave.digital/45604";
const episodes = await fetchPodcastFeed(podcastUrl);
const playerContainer = document.createElement("div");
playerContainer.innerHTML = `
`;
document.body.appendChild(playerContainer);
const audioPlayer = document.getElementById("audioPlayer");
const playlist = document.getElementById("playlist");
episodes.forEach((episode, index) => {
const listItem = document.createElement("li");
listItem.textContent = episode.title;
listItem.onclick = () => {
audioPlayer.src = episode.enclosure.link;
audioPlayer.play();
};
playlist.appendChild(listItem);
});
}
createPodcastPlayer();