Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
add file for reppo
  • Loading branch information
prchapagain authored Jul 21, 2024
1 parent c03fd13 commit d75889f
Show file tree
Hide file tree
Showing 3 changed files with 669 additions and 0 deletions.
74 changes: 74 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nepali Radio Player</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="icon" type="image/png" href="https://res.cloudinary.com/dk8kcwpov/image/upload/v1721548253/favicon-32x32_zjc02y.png">

</head>
<div class="header">
<div class="topnav">
<a class="active" href="/">Home</a>
<a href="/tabs/blog/">News</a>
<a href="/tabs/projects.html">Projects</a>
<a href="/tabs/links.html">Links</a>
</div>
<body>
</body>
<body>
<div class="handle"></div>
<div class="radio-container">
<div class="radio-body">
<div class="radio-speaker"></div>
<div class="radio-display">
<div class="radio-text" id="current-station">Nepali RADIO</div>
<div class="radio-text" id="current-station"> <span class="indicator" id="streaming-indicator"></span></div>
</div>
<div class="radio-buttons">
<button class="radio-button" id="play-pause" onclick="playPause()">Play</button>
<button class="radio-button" id="prev-station" onclick="prevStation()">Prev</button>
<button class="radio-button" id="next-station" onclick="nextStation()">Next</button>
</div>
<div class="radio-knob">
<div class="knob-center"></div>
</div>
</div>
<div class="radio-antenna"></div>
</div>
<div class="fm-list-container">
<button class="toggle-fm-list" onclick="toggleFMList()">Show/Hide FM List</button>
<div class="fm-list" id="fm-list">
<ul id="fm-list-ul">

</ul>
</div>
</div>
<div class="footer">

Made with ♥ by PR chapagain
<button class="alert"><img src="https://res.cloudinary.com/djcw5veb6/image/upload/v1719727590/about-xxl_ybbg2a.png" alt="about"></button>

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script>
let custom_button = document.querySelector(".alert");
custom_button.addEventListener('click', function () {
Swal.fire({
title: "<strong>Nepali Radio Player</strong>",
icon: "info",
html: `this player is created by PR CHAPAGAIN<br>
<a href="prchapagain.github.io">prchapagain.github.io</a><br>
<br>
visit project link <a href="https://github.com/prchapagain.github.io/nepali-radio-player"><b>here</b></a> for suggestions or help to improve player.`,
showCloseButton: true,
focusConfirm: false,
confirmButtonText: "close",
});
});
</script>
</div>
<script src="script.js"></script>
</body>
</html>
179 changes: 179 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
// THIS JAVA MADE BY PR CHAPAGAIN//
let currentStationIndex = 0;
let currentlyPlayingButton = null;
const stations = [
{ name: "Radio Nepal", streamUrl: "https://stream1.radionepal.gov.np/live/" },
{ name: "Kantipur FM", streamUrl: "https://radio-broadcast.ekantipur.com/stream/" },
{ name: "Ujyalo 90 Network", streamUrl: "https://stream.zeno.fm/h527zwd11uquv" },
{ name: "Kalika FM", streamUrl: "http://kalika-stream.softnep.com:7740/;" },
{ name: "Galyang FM", streamUrl: "https://live.itech.host:9107/stream" },
{ name: "Radio Audio", streamUrl: "https://stream.zeno.fm/fvrx47wpg0quv" },
{ name: "Shreenagar FM", streamUrl: "https://live.itech.host:9598/stream" },
{ name: "Radio Bhorukawa", streamUrl: "https://live.itech.host:8379/stream" },
{ name: "Hits FM", streamUrl: "https://usa15.fastcast4u.com/proxy/hitsfm912?mp=/1" },
{ name: "Radio Annapurna Nepal", streamUrl: "https://shoutcast.prixa.live/annapurna" },
{ name: "BFBS Gurkha Radio", streamUrl: "https://listen-ssvcbfbs.sharp-stream.com/ssvcbfbs3.aac" },
{ name: "Radio Tufan", streamUrl: "https://stream.zeno.fm/60tx8fw9dd0uv" },
{ name: "Capital FM", streamUrl: "https://streaming.softnep.net:10982/;stream.nsv&type:mp3&volume:10" },
{ name: "Radio Amargadhi", streamUrl: "https://live.itech.host:8927/stream" },
{ name: "Barahathawa FM 101.1Mhz", streamUrl: "https://stream.zeno.fm/gubb557z4k8uv" },
{ name: "Sky FM 106.6", streamUrl: "https://onlineradio.websoftitnepal.com/8002/stream" },
{ name: "Shuklaphanta FM", streamUrl: "https://streaming.webhostnepal.com/8010/stream" },
{ name: "Good News FM", streamUrl: "https://live.itech.host:8167/stream?1611505122592" },
{ name: "Radio Resunga", streamUrl: "https://live.itech.host:3260/stream" },
{ name: "Radio Rudraksha", streamUrl: "https://streaming.softnep.net:10874/;stream.nsv&type:mp3&volume:50" },
{ name: "Classic FM", streamUrl: "https://stream.hamropatro.com/8783" },
{ name: "Times FM", streamUrl: "https://astream.nepalipatro.com.np:8119/index.html" },
{ name: "Pathibhara FM", streamUrl: "https://live.itech.host:8749/stream" },
{ name: "Krishnasar FM", streamUrl: "https://live.itech.host:8434/stream" },
{ name: "Synergy FM", streamUrl: "https://live.itech.host:3880/stream" },
{ name: "Radio Prakriti", streamUrl: "https://live.itech.host:8939/stream" },
{ name: "Radio Nepalbani", streamUrl: "https://live.itech.host:8681/stream" },
{ name: "Radio Marsyangdi", streamUrl: "https://streaming.webhostnepal.com:7032/;stream.nsv&type:mp3&volume:30" }
];

let audio = new Audio(stations[currentStationIndex].streamUrl);

audio.addEventListener('canplay', function() {
console.log('Audio can play:', stations[currentStationIndex].name);
document.getElementById('streaming-indicator').style.display = 'inline-block'; // Show indicator
});

audio.addEventListener('error', function(e) {
console.error('Audio error:', e);
document.getElementById('streaming-indicator').style.display = 'none'; // Hide indicator
});

document.addEventListener('DOMContentLoaded', () => {
const fmListUl = document.getElementById('fm-list-ul');
stations.forEach((station, index) => {
const li = document.createElement('li');
li.setAttribute('onclick', `selectStation(${index})`);

const span = document.createElement('span');
span.textContent = station.name;

const button = document.createElement('button');
button.className = 'like-button';
button.textContent = 'Play';
button.setAttribute('onclick', 'likeStation(this); event.stopPropagation();');

li.appendChild(span);
li.appendChild(button);
fmListUl.appendChild(li);
});

// Attempt to autoplay the first station
audio.play().then(() => {
console.log('Autoplaying:', stations[currentStationIndex].name);
document.getElementById('current-station').innerText = stations[currentStationIndex].name;
document.getElementById('play-pause').innerText = 'Pause';
updateStationButton(currentStationIndex);
document.getElementById('streaming-indicator').style.display = 'inline-block'; // Show indicator
}).catch(e => {
console.error('Autoplay blocked:', e);
document.getElementById('play-pause').innerText = 'Play';
document.getElementById('streaming-indicator').style.display = 'none'; // Hide indicator
});

// Block right-click context menu
document.addEventListener('contextmenu', event => event.preventDefault());

// Block F12, Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+Shift+C, and Ctrl+U
document.addEventListener('keydown', function(e) {
if (e.keyCode === 123 || // F12
(e.ctrlKey && e.shiftKey && (e.keyCode === 73 || e.keyCode === 74 || e.keyCode === 67)) || // Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+Shift+C
(e.ctrlKey && e.keyCode === 85)) { // Ctrl+U
e.preventDefault();
}
});
});

function toggleFMList() {
const fmList = document.getElementById('fm-list');
fmList.style.display = fmList.style.display === 'none' || fmList.style.display === '' ? 'block' : 'none';
}

function likeStation(button) {
// Stop the currently playing station, if any
if (currentlyPlayingButton && currentlyPlayingButton !== button) {
currentlyPlayingButton.innerText = 'Play';
currentlyPlayingButton.style.backgroundColor = ''; // Reset to default color
}

// Update the clicked button to show it's playing
button.innerText = 'playing';
button.style.backgroundColor = '#ff3b30';

// Update the reference to the currently playing button
currentlyPlayingButton = button;

// Play the selected station
const index = Array.from(button.parentElement.parentElement.children).indexOf(button.parentElement);
selectStation(index);
}

function playPause() {
const playPauseButton = document.getElementById('play-pause');
if (audio.paused) {
audio.play().then(() => {
playPauseButton.innerText = 'Pause';
console.log('Playing:', stations[currentStationIndex].name);
document.getElementById('streaming-indicator').style.display = 'inline-block'; // Show indicator
}).catch(e => {
console.error('Error playing audio:', e);
});
} else {
audio.pause();
playPauseButton.innerText = 'Play';
document.getElementById('streaming-indicator').style.display = 'none'; // Hide indicator
}
}

function prevStation() {
currentStationIndex = (currentStationIndex - 1 + stations.length) % stations.length;
updateStation();
}

function nextStation() {
currentStationIndex = (currentStationIndex + 1) % stations.length;
updateStation();
}

function selectStation(index) {
currentStationIndex = index;
updateStation();
}

function updateStation() {
// Stop the current audio before changing the source
audio.pause();
document.getElementById('streaming-indicator').style.display = 'none'; // Hide indicator during transition
audio.src = stations[currentStationIndex].streamUrl;
audio.play().then(() => {
console.log('Now playing:', stations[currentStationIndex].name);
document.getElementById('streaming-indicator').style.display = 'inline-block'; // Show indicator
}).catch(e => {
console.error('Error playing audio:', e);
document.getElementById('streaming-indicator').style.display = 'none'; // Hide indicator
});
document.getElementById('current-station').innerText = stations[currentStationIndex].name;
document.getElementById('play-pause').innerText = 'Pause';

// Update the button text and color for the currently playing station
updateStationButton(currentStationIndex);
}

function updateStationButton(index) {
const buttons = document.querySelectorAll('.like-button');
buttons.forEach((button, i) => {
if (i === index) {
button.innerText = 'playing';
button.style.backgroundColor = '#ff3b30';
currentlyPlayingButton = button;
} else {
button.innerText = 'Play';
button.style.backgroundColor = ''; // Reset to default color
}
});
}
Loading

0 comments on commit d75889f

Please sign in to comment.