simple internet radio built using web 2.0 technology

This commit is contained in:
arul 2024-11-11 18:36:03 +01:00
commit 4d7001c399
5 changed files with 214 additions and 0 deletions

0
README.md Normal file
View File

23
channels.md Normal file
View File

@ -0,0 +1,23 @@
Rainbow FM 6, https://air.pc.cdn.bitgravity.com/air/live/pbaudio022/playlist.m3u8
Radio Mirchi Tamil, https://tamil.crabdance.com:8002/1
Radio City Live, https://tamil.crabdance.com:8002/5
MGR/Sivaji Hits, https://stream.zeno.fm/pq4yq4qri9yvv
Chennai City FM, https://stream.zeno.fm/cn8sh3supsnvv
American Tamil Radio, https://cp11.serverse.com/proxy/hgsmgluv/stream
British Indian Tamil Radio, https://hello.citrus3.com:2020/stream/britishindiantamilradio
Cuckoo Tamil Comedy Radio, https://radio-proxy.arulbalaji.xyz/audio-stream/cuckoo-tamil-comedy/
Goundamani Senthil Radio, https://radio-proxy.arulbalaji.xyz/audio-stream/goundamanisenthil-radio/
Vadivelu Comedy Radio, https://radio-proxy.arulbalaji.xyz/audio-stream/vadivelu-comedy-radio/
Tamil Comedy Radio, https://radio-proxy.arulbalaji.xyz/audio-stream/tamil-comedy-radio/
Sooriyan FM, https://www.liveradio.es/http://radio.lotustechnologieslk.net:8006/;stream.mp3
Tamil 80s Radio, https://stream-164.zeno.fm/48w230kx8vzuv
Tamil FM 89.4, https://centova.aarenworld.com/proxy/894tamilfm/stream
Big FM 92.7, https://tamil.crabdance.com:8002/4
Tamil Panpalai Radio, https://tamilpanpalai.radioca.st/ind
Air Chennai FM Gold 102.3, https://air.pc.cdn.bitgravity.com/air/live/pbaudio021/playlist.m3u8
IlayaRaja Voice, https://stream.zeno.fm/qfd4vokvu3dvv
GV Prakash Radio, https://stream.zeno.fm/c9cxafngfekvv
SPB Old Hits, https://stream.zeno.fm/lgukkevrihmvv
AR Rahman FM, https://www.liveradio.es/http://stream.zeno.fm/ihpr0rqzoxquv
Harris Jayaraj Radio, https://stream-158.zeno.fm/0bhsthssutzuv
Santhosh Narayanan Radio, https://stream.zeno.fm/wkqvzsg1238uv

6
fix-permission Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
sudo chown arul:arul /var/www/html/Internet-Radio/channels.md
sudo chmod 644 /var/www/html/Internet-Radio/channels.md

171
index.html Normal file
View File

@ -0,0 +1,171 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Radio Stream Player</title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
font-family: Arial, sans-serif;
background-color: #000;
color: #fff;
flex-direction: column;
}
.container {
text-align: center;
max-width: 90%;
width: 400px;
padding: 20px;
background: transparent;
border-radius: 10px;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.3);
border: 1px solid #fff;
}
h1 {
margin-bottom: 10px;
font-size: 1.5rem;
}
select {
padding: 10px;
font-size: 16px;
border: 1px solid #fff;
background-color: #333;
color: #fff;
cursor: pointer;
width: 100%;
max-width: 100%;
margin-top: 10px;
border-radius: 5px;
}
audio, iframe {
width: 100%;
margin-top: 15px;
display: none; /* Initially hidden */
}
iframe {
height: 250px;
border-radius: 8px;
border: none;
object-fit: cover;
}
/* Mobile responsiveness */
@media (max-width: 768px) {
.container {
padding: 15px;
}
h1 {
font-size: 1.3rem;
margin-bottom: 8px;
}
iframe {
height: 200px;
}
}
@media (max-width: 480px) {
h1 {
font-size: 1.1rem;
margin-bottom: 5px;
}
iframe {
height: 180px;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Radio Stream Player</h1>
<select id="channelSelect">
<option value="off">OFF</option>
</select>
<audio id="audioPlayer" controls></audio>
<iframe id="streamIframe" src="about:blank" allowfullscreen></iframe>
</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
const channelSelect = document.getElementById('channelSelect');
const audioPlayer = document.getElementById('audioPlayer');
const streamIframe = document.getElementById('streamIframe');
// Fetch channels from channels.md
fetch('channels.md')
.then(response => response.text())
.then(text => {
const lines = text.split('\n');
lines.forEach(line => {
const [name, url] = line.split(',').map(item => item.trim());
if (name && url) {
const option = document.createElement('option');
option.value = url;
option.textContent = name;
channelSelect.appendChild(option);
}
});
})
.catch(error => console.error('Error loading channels.md:', error));
// Event listener for channel selection
channelSelect.addEventListener('change', function() {
const selectedUrl = this.value;
resetPlayer(); // Reset player before selecting the new channel
if (selectedUrl === 'off') return; // Do nothing if 'OFF' is selected
if (selectedUrl.endsWith('.m3u8')) {
playHLS(selectedUrl); // Play using HLS.js
} else if (selectedUrl.includes('crabdance.com')) {
streamIframe.src = selectedUrl;
streamIframe.style.display = 'block';
} else {
playAudio(selectedUrl); // Regular audio stream
}
});
// Function to reset and stop any ongoing media
function resetPlayer() {
if (!audioPlayer.paused) {
audioPlayer.pause();
audioPlayer.src = ''; // Clear the audio source
}
audioPlayer.style.display = 'none'; // Hide audio player
streamIframe.src = ''; // Clear iframe source
streamIframe.style.display = 'none'; // Hide iframe
}
// Function to play regular audio
function playAudio(url) {
audioPlayer.src = url;
audioPlayer.style.display = 'block'; // Show the audio player
audioPlayer.play().catch((error) => {
console.error('Error playing audio:', error);
});
}
// Function to play HLS stream using Hls.js
function playHLS(url) {
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(audioPlayer);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
audioPlayer.style.display = 'block';
audioPlayer.play().catch((error) => {
console.error('Error playing HLS stream:', error);
});
});
} else {
alert('HLS is not supported in your browser');
}
}
</script>
</body>
</html>

14
server Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Start a simple HTTP server using Python
PORT=8001
echo "Starting HTTP server on port $PORT..."
# Check if Python 3 is installed
if command -v python3 &>/dev/null; then
python3 -m http.server $PORT
else
echo "Python 3 is not installed. Please install it to run the server."
exit 1
fi